Is there a way to make multiple choices?
Currently, only single selection seems to be supported. How about making Selection support Set<Data.Element>?
Not currently. But, I’m happily accepting PRs 🙂
Currently testing. If it goes well, I'll send a PR!
@wogus3602 have you made any progress on this? If not, I'd be interested in helping work on it.
I haven't done anything like this, but I think the challenging part for me would be how to allow initializers to use either Binding<Set<Data.Element>> or Binding<Data.Element>, while the OutlineView's internal variable is... what? Binding to a Set with a hard limit to one element if the initializer was the single-selection variety? How did you plan on going about it?
@RCCoop I worked on multi-select as below.
@Binding var selection: Set<Item>
init(
selection: Binding<Item?>,
children childrenKeyPath: ChildrenKeyPath<Item>? = nil,
content: @escaping ListItemContentType<Item>
) {
self._selection = .init {
if let sel = selection.wrappedValue {
return Set([sel])
}
return Set()
} set: { newValue in
selection.wrappedValue = newValue.first
}
self.content = content
self.childrenKeyPath = childrenKeyPath
}
init(
selection: Binding<Set<Item>>,
children childrenKeyPath: ChildrenKeyPath<Item>? = nil,
content: @escaping ListItemContentType<Item>
) {
self._selection = selection
self.content = content
self.childrenKeyPath = childrenKeyPath
}
@RCCoop The multi-select work is complete, so I'll post a PR soon.
@wogus3602 Very cool! Thanks for working on that :-)