https://github.com/adriantabirta/statetableview
Tableview states for loading, refreshing and placeholders.
https://github.com/adriantabirta/statetableview
ios swift3 swift4 tableview tableview-collectionview-loading
Last synced: 3 months ago
JSON representation
Tableview states for loading, refreshing and placeholders.
- Host: GitHub
- URL: https://github.com/adriantabirta/statetableview
- Owner: adriantabirta
- Created: 2018-02-21T15:57:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-04T09:54:38.000Z (about 8 years ago)
- Last Synced: 2025-01-20T08:22:18.519Z (over 1 year ago)
- Topics: ios, swift3, swift4, tableview, tableview-collectionview-loading
- Language: Swift
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# StateTableView
### TableView exemple for states.
###### Tableview extenions for statle like:
- [x] initial
- [x] initialRefreshable
- [x] empty
- [x] loading
- [x] noConnection
###### This it is an exemple how to make tableview placeholders. Customize views like you want and use it.
###### Gif

## Getting Started
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:
```swift
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() {
// ...
}
```