I have this:
protocol Selectable: Identifiable {
associatedtype Label : View
var isSelected: Bool { get set }
var label: Label { get }
}
struct Multiselect<T: Selectable>: View {
@Binding var items: [T]
var body: some View {
List {
ForEach($items) { index, item in
Toggle(isOn: item.isSelected) {
item.wrappedValue.label
}
}
}
}
}
Selectable
is too common/general, nesting it inside Multiselect
, if possible would be ideal, but it's not allowed.
I want to avoid naming it MultiselectSelectable
Is there any good solution?