Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 1.25 KB

README.md

File metadata and controls

45 lines (32 loc) · 1.25 KB

SelectableCollectionView

build

SwiftUI collection view with selection support.

Documentation

https://inseven.github.io/SelectableCollectionView/documentation/selectablecollectionview/

Usage

struct ContentView: View {

    @State private var items = [/* ... */]

    private var columns = [GridItem(.adaptive(minimum: 300))]

    /* ... */

    var body: some View {
        HStack {
            SelectableCollectionView(model.filteredItems,
                                     selection: $model.selection,
                                     columns: columns) { item in
                ItemView(item: item)
            } contextMenu: { selection in
                MenuItem("Delete") {
                    items.removeAll { selection.contains($0.id) }
                }
            } primaryAction: { selection in
                for item in items.removeAll(where: { selection.contains($0.id) }) {
                    /* ... */
                }
            }
        }
    }

}

License

SelectableCollectionView is licensed under the MIT License (see LICENSE).