- initial
- initialRefreshable
- empty
- loading
- noConnection
Is easy to implement, just drag and drom into your project folders: Views and Extensions. Download repository and run on the simulator. Application simulate network requests with different responses. Refresh for simulate requests.
Here is an exemple code how to use it:
class ViewController: UIViewController {
// ...
override func viewDidLoad() {
super.viewDidLoad()
// this is important to setup
tableview?.datasourceReference = self
// configure initial tableview state
tableview?.configure(state: .loading(LoadingView(frame: self.tableview?.frame ?? CGRect.zero)))
}
func loadData() {
// create an loading view and set it.
let loagindView = LoadingView(frame: self.tableview?.frame)
tableview?.configure(state: .loading(loagindView))
// ... you loading data code here
// on empty data, use your placehoder
let nodataView = NoDataView()
self.tableview?.configure(state: .empty(nodataView))
// on lost connection
let noConnectionView = NoConnectionView(frame: self.tableview?.frame ?? CGRect.zero).onTryAgain(self.refreshAction)
self.tableview?.configure(state: .noConnection(noConnectionView))
}
func refreshAction() {
// ...
}