I have a list of items, they are displayed in decreasing order by amount in a list. I hash them by name, so when I change the amounts, they should reorder smoothly on apply.
When I call the apply(snapshot, animatingDifferences: true)
function on UICollectionViewDiffableDataSource
, it doesn't reorder the cells with a smooth animation, but flashes instead and everything is in place with no "reordering".
struct Item: Hashable {
let name: String
let amount: Int
func hash(into hasher: inout Hasher) {
hasher.combine(name)
}
}
// when user taps, I call this
dataSource.apply(makeSnapshot())