SwiftUI's default List behaviour for changing sizes of existing List items is different to inserting new ones (no scrolling vs scrolling visible items).
I want them to both not scroll. In my app, there are legitimately a large number of updates that happen almost immediately in the List View, and I don't want the user to lose their place, which happens if updates trigger the currently viewable list of items to move down.
This simple example shows the two behaviours.
How to use example:
- Add some items
- Scroll down.
- Resize some items. It resizes items from the top item first.
- Notice that the view you see is unaffected until the items on the screen are changed ("not scrolling"). It appears to be offsetting the position of the List such that the currently visible portion is unchanged.
- Now add some items. Notice that inserting the items pushes the current items down ("scrolling"). In this case it does not seem to attempt to offset the position of the List, and so the items, with new content, are moved down.
I'd like to customise the List behaviour (iOS16+ is ok) so that the insertion behaviour is the same as the update behaviour.
Does anyone know the best way to do this? Do I have to rebuild using UICollectionView (which is I believe how List is implemented under iOS16…?)