Skip to content

Tableview states for loading, refreshing and placeholders.

Notifications You must be signed in to change notification settings

adriantabirta/StateTableView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

StateTableView

TableView exemple for states.

Tableview extenions for statle like:
  • initial
  • initialRefreshable
  • empty
  • loading
  • noConnection
This it is an exemple how to make tableview placeholders. Customize views like you want and use it.
Gif

Alt Text

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:

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() {
    // ...
  }
 
  
  

About

Tableview states for loading, refreshing and placeholders.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages