Add disable for multiselect row

This commit is contained in:
Arkadiusz Fal 2022-08-14 19:02:36 +02:00
parent 1f74aaa923
commit ce4f07e788

View File

@ -2,7 +2,8 @@ import SwiftUI
struct MultiselectRow: View {
let title: String
let selected: Bool
var selected: Bool
var disabled = false
var action: (Bool) -> Void
@State private var toggleChecked = false
@ -16,6 +17,7 @@ struct MultiselectRow: View {
Spacer()
}
.onAppear {
guard !disabled else { return }
toggleChecked = selected
}
.onChange(of: toggleChecked) { new in
@ -34,6 +36,7 @@ struct MultiselectRow: View {
}
.contentShape(Rectangle())
}
.disabled(disabled)
#if !os(tvOS)
.buttonStyle(.plain)
#endif