Last active
November 5, 2017 16:05
-
-
Save sauvikdolui/60775442bb6a17817f5506d211c484e9 to your computer and use it in GitHub Desktop.
Medium Blog Post SDStateTableView state mangement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: IBActions | |
extension ViewController { | |
@IBAction func dataAvailableButtonTapped(_ sender: UIButton) { | |
stateTableView.setState(.dataAvailable) | |
} | |
@IBAction func noDataAvailableButtonTapped(_ sender: UIButton) { | |
stateTableView.setState(.withImage(image: "empty_cart", | |
title: "EMPTY CART", | |
message: "Please add some item in your cart first")) | |
} | |
@IBAction func errorWithImageButtonTapped(_ sender: UIButton) { | |
stateTableView.setState(.withImage(image: "server_error", | |
title: "SERVER ERROR", | |
message: "We are notified and working on it, we will be back soon")) | |
} | |
@IBAction func errorWithTitleButtonTapped(_ sender: UIButton) { | |
stateTableView.setState(.withImage(image: nil, | |
title: "SIMPLE ERROR TITLE", | |
message: "Error message goes here")) | |
} | |
@IBAction func loadingDataButtonTapped(_ sender: UIButton) { | |
stateTableView.setState(.loading(message: "Loading data...")) | |
} | |
@IBAction func noInternetButtonTapped(_ sender: Any) { | |
stateTableView.setState(.withButton(errorImage: "no_internet", | |
title: "NO INTERNET", | |
message: "You are not connected to Internet, please try later", | |
buttonTitle: "Try Again", | |
buttonConfig: { (button) in | |
// configure the button as per your requirement | |
}, | |
retryAction: { | |
self.stateTableView.setState(.loading(message: "Loading data...")) | |
})) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment