apptekstudios / ASCollectionView

A SwiftUI collection view with support for custom layouts, preloading, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow updating selection based on programmatic changes to `selectedItems`

atdrendel opened this issue · comments

As currently configured, selection in ASCollectionView (and Apple's own List) is exposed as Binding<Set<SelectionValue>>. According to Apple's own documentation, a binding is "a two-way connection between a property that stores data, and a view that displays and changes the data". However, in ASCollectionView and Apple's own List, the binding is only a one-way connection: the internal collection view can update the selection, but the consumer can't update it. This causes problems when trying to implement some common iOS idioms based on selection, such as presenting a modal sheet or deep linking to some view deep in an app's view hierarchy.

It would be nice to allow ASSectionDataSource.selectedItems to be set from the consumer of the library instead of only being updatable by the internal UICollectionView.