Just getting started with SwiftUI. Exciting stuff.
I understand that List would be one of the main building blocks that I can use in place of UI/NSTableView. One thing I haven’t seen yet: how to get and set the scroll position? Specifically, my list would consist of “read” and “unread” items. When the user first enters the list, everything is unread, so the list can start at the top. As new items scroll into view, they become “read”. When the user now leaves the list, and later returns, the list should scroll to the first “unread” item. So I am not so much interested in the pixel-level scroll offset, but rather, how do I scroll the viewport into the right location so that the user would see the desired info. The API could be something like “scroll the list such that model object X is visible in the middle” (with or without animation).
The read/unread state is easily expressible as a model object property. I’m having trouble with how to bind it to the list scrolling in this new declarative world of ours.
If using a ScrollView instead of list, there is new API for setting the scroll position: https://developer.apple.com/documentation/swiftui/scrollviewproxy/scrollto(_:anchor:)
I discussed this with Apple engineers during a SwiftUI lab. No clean API to get scroll position to implement something like infinite load. But at least we can set it cleanly now. For many cases of displaying content, using ScrollView + LazyVStack is better than using a List, and then we can also use this new API.