A list implementation that can preserve position
This is a SwiftUI wrapper around NS
/UITableView
. It is superfically-similar to SwiftUI's List
, but with an additional property that can be used to control scroll position.
Warning
I'm just experimenting at the moment. This only kind of works.
dependencies: [
.package(url: "https://github.com/mattmassicotte/StableView", branch: "main")
]
The position preservation system works via the scrollState
binding.
struct AnchoredView: View {
let items = ["one", "two", "three"]
@State private var position: AnchoredListPosition<String>? = AnchoredListPosition(item: "two")
public var body: some View {
AnchoredList(items: items, position: $position) { item, row in
Text("item: \(item)")
}
}
}
I would love to hear from you! Issues or pull requests work great. Both a Matrix space and Discord are available for live help, but I have a strong bias towards answering in the form of documentation. You can also find me on the web.
I prefer collaboration, and would love to find ways to work together if you have a similar project.
I prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.
By participating in this project you agree to abide by the Contributor Code of Conduct.