0

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.

Dawy
  • 770
  • 6
  • 23

0 Answers0