mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 14:03:41 +00:00
Add disable for multiselect row
This commit is contained in:
parent
601523ab1b
commit
c23b42f76c
@ -2,7 +2,8 @@ import SwiftUI
|
|||||||
|
|
||||||
struct MultiselectRow: View {
|
struct MultiselectRow: View {
|
||||||
let title: String
|
let title: String
|
||||||
let selected: Bool
|
var selected: Bool
|
||||||
|
var disabled = false
|
||||||
var action: (Bool) -> Void
|
var action: (Bool) -> Void
|
||||||
|
|
||||||
@State private var toggleChecked = false
|
@State private var toggleChecked = false
|
||||||
@ -16,6 +17,7 @@ struct MultiselectRow: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
|
guard !disabled else { return }
|
||||||
toggleChecked = selected
|
toggleChecked = selected
|
||||||
}
|
}
|
||||||
.onChange(of: toggleChecked) { new in
|
.onChange(of: toggleChecked) { new in
|
||||||
@ -34,8 +36,9 @@ struct MultiselectRow: View {
|
|||||||
}
|
}
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
}
|
}
|
||||||
|
.disabled(disabled)
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user