CollectionView

main

SwiftUI wrapper of UICollectionView.
edonv/CollectionView

CollectionView

CollectionView is a SwiftUI wrapper of UICollectionView.

Have you ever wanted to make an app solely in SwiftUI, but the processing tradeoff of using Grid, Lazy_Stack, and Lazy_Grid are too significant? Wish you could stick with SwiftUI but still get the processing power of UICollectionView? Then try out CollectionView!

It’s a SwiftUI wrapper for UICollectionView that exposes all UICollectionViewDelegate/UICollectionViewDataSourcePrefetching delegate functions (via view modifiers). Plus, on iOS 16+, you can utilize UIHostingConfiguration to use SwiftUI views for the cells.

Plus, by passing your data source as a Binding, it updates changes to the view using UICollectionViewDiffableDataSource. This also means it doesn't fully reload the view on every change, but rather, they're reloaded internally by the UICollectionView.

It’s still a work in progress (especially with testing everything + documentation), but please give it a try and send feedback my way!

Usage

  • Make sure to use .ignoresSafeArea() if it's meant to be full-screen.

To-Do's

  • Implement UICellConfigurationState.
  • Add support for NSCollectionView.
  • Make sure CollectionView isn't updating itself more than necessary? or is it not because it's a RepresentableView?
  • Condense initializers somehow...
  • Add support for section snapshots.
    • Add support for expandable sections.
  • Add support for section headers/footers.
  • Refactor cellRegistrationHandler out of primary initializers and replace with a UICollectionViewDiffableDataSource<Section, Item>.CellProvider closure to allow for more complicated configurations.
  • Finish documenting view modifiers.
  • Work on more concrete example for README/DocC articles.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 18 2024 01:20:12 GMT-0900 (Hawaii-Aleutian Daylight Time)