'How to select just one Toggle in LazyVGrid
I use LazyVGrid to show set of data and as one column I'd like to use Toggle view to allow multiple lines selection. If I do it like this
ScrollView {
LazyVGrid(columns: columns) {
ForEach(data, id:\.id) { record in
Toggle("", isOn: $selected).onChange(of: selected) { sel in
print(record.id!)
}
Text("\(dateFormatter.string(from: record.start!))")
}
}
}
then (of course) all rows are selected or unselected being all binded to selected @State var. What's best practice here to allow individual lines selection? Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
