Declarative wrapper for UIKit Diffable Data Source. Describe content, call set() — diffing and animations handled automatically.
Repo sparrowcode/DiffableKit, read from GitHub 9 h ago. sparrowcode has not joined Take My Repo.
A list no longer wipes a custom section header or footer when set refreshes the text ones. Before, any header or footer from a HeaderFooterProvider built on UICollectionViewListCell got an empty text configuration on the next set and lost its content. Now only the text headers and footers DiffableKit makes itself are refreshed.
In Debug, a table, list or collection stops with a clear message when an item on screen comes back under the same id with a different type, for example a button row replaced by a plain row. Such an item is reconfigured, and UIKit can't move it to another cell, so before it crashed deep inside apply with "Attempted to dequeue a cell for a different registration" and no item name. Give items of different types different ids. Release builds don't include the check.
A switch row that is already on screen moves to its new value with the system animation when the list reconfigures it, for example when another control on the screen turns it off. Before, the value jumped into place. New and reused cells still take the value without animation.
Lists keep their bottom inset in step with the keyboard through the system keyboard layout guide, recounted on every layout. Before, the inset was counted once from the keyboard notification: a popover or a sheet on iPad that then moved away from the keyboard kept the inset for its old size, and the list stayed scrolled with its first rows under the bar.
Under a modal, list and table cells no longer swap a symbol image for a desaturated bitmap. That bitmap came out black and lost the symbol metrics, so the icon darkened and shrank. Symbols are coloured by the tint, so UIKit dims them itself, together with tinted text; cells still desaturate raster images, which UIKit leaves as they are.
A list can use its own layout subclass: DiffableListController and DiffableListView get init(layout:) next to init(appearance:). Pass a DiffableListLayout subclass, for example one with its own layoutAttributesClass that hands extra per-item data to cells in apply(_:). The subclass reads the list's data source through DiffableListLayout.dataSource to find the section and item at an index path.