This is a simple example of infinity scroll. How add infinity to Up scroll
and insert rows at beginning:
rows.insert(contentsOf: Array(repeating: "Item 0", count: 20), at: 0)
Like apple do this trick in calendar.
struct Screen: View {
@State var rows: [String] = Array(repeating: "Item", count: 20)
private func getNextPageIfNecessary(encounteredIndex: Int) {
guard encounteredIndex == rows.count - 1 else { return }
rows.append(contentsOf: Array(repeating: "Item", count: 20))
}
var body: some View {
...
List(0..<rows.count, id: \.self) { index in
Text(verbatim: self.rows[index])
.onAppear {
self.getNextPageIfNecessary(encounteredIndex: index)
}
}