The “Discoverable Design“ session showcases the app Toasty, and it's “Recipes“ has a grid of items where the first one is an invitation to add a new photo (i.e. a static cell).
To replicate that concept in my collectionView, I need advice how best to approach it.
My collectionView has a single section and is powered by a UICollectionViewDiffableDataSource, which is populated from a NSFetchedResultsController and relies on CellRegistration. In addition, the user can change the sort order, which updates fetchedResultsController's sortDescriptors and performs a fetch.
My failed approach was focused on the dataSource snapshot built in fetchedResultsController's didChangeContentWith. First I appended the snapshot with a dummy entry, and then appended all fetchedObjects. I made sure that the dataSource constructor used a different cell registration for the (0,0) IndexPath. This however resulted in indexPath mismatches between the collectionView and FRC, and I don't think remapping indexPaths is the way to go.
Point me in the right direction? Is there a way to configure the collectionView layout for this?
Figured it out. My main mistake was using objects and not identifiers in UICollectionViewDiffableDataSource. When it's using identifiers, the data has to be prepared in CellRegistration. With an indexPath coming in, it's easy to remap what you're retrieving from FRC.
Now that I've solved the problem, I've decided against the design pattern of static first cell on account that it goes out of sight for users browsing the collectionView. When the Add button is placed in UINavigationBar or the toolbar, however, it's always in sight.