SwiftUI List with pull-to-refresh and infinite scroll

6134
0

Lists are fundamental to iOS apps, displaying scrollable collections efficiently. SwiftUI's List or ScrollView with LazyVStack renders items on-demand. I add pull-to-refresh with the .refreshable modifier, calling async refresh logic. For infinite scroll, I detect when the last item appears using onAppear and trigger pagination. The ViewModel tracks current page and hasMore state. Pagination prevents duplicate loads with loading flags. For performance with large datasets, I use LazyVStack instead of VStack to avoid rendering off-screen views. This pattern provides smooth, responsive lists that scale to thousands of items.