SwiftUI Pagination
Pagination in SwiftUI & MVVM.
In this example I'll show how to handle pagination:
1) Let's start with our ContentView: a ZStack with a Progress View & a List (Table) of items:
2) Our ViewModel will have the items array for the data, isLoading bool for the progress animation, and a fake network request function to simulate the request for data fetch:
3) Last - our custom ListViewCell. something very simple just for the example:
You can find the code here:
And The Result:
Founder @ Stealth Startup | Sr. Software Engineer
2 年Nice, another way is to load the items in the ForEach and apply a function to check , because you often need the item in the block, I personally dont like accessing it using the index (viewModel.items[i] , i+ 1 == last ) etc..
Data Analyst –Extracting business insights from large datasets enabling various profit-maximizing actions. Assists athletes in determining their data-driven market value and how to increase it | Python | SQL | Excel
2 年looks great!!