Server Offline Activity Indicator (#6314)

* Server Offline Activity Indicator

- implemented
This commit is contained in:
Gil Eluard
2022-07-05 14:04:52 +02:00
committed by GitHub
parent 4c84d1b15c
commit f91e84af00
15 changed files with 179 additions and 14 deletions
@@ -24,6 +24,13 @@ import CommonKit
private let presenter: UserIndicatorTypePresenterProtocol
private var indicators: [UserIndicator]
@objc init(from viewController: UIViewController) {
self.presenter = UserIndicatorTypePresenter(presentingViewController: viewController)
self.indicators = []
super.init()
}
init(presenter: UserIndicatorTypePresenterProtocol) {
self.presenter = presenter
self.indicators = []
@@ -59,4 +66,24 @@ import CommonKit
let indicator = presenter.present(.success(label: label))
indicators.append(indicator)
}
/// Present an error message that will be automatically dismissed after a few seconds.
///
/// Note: This is a convenience function callable by objective-c code
@objc func presentFailure(label: String) {
let indicator = presenter.present(.failure(label: label))
indicators.append(indicator)
}
/// Present an custom message
/// To remove the indicator call the returned `UserIndicatorCancel` function
///
/// Note: This is a convenience function callable by objective-c code
@objc func presentCustom(label: String, icon: UIImage?) -> UserIndicatorCancel {
let indicator = presenter.present(.custom(label: label, icon: icon))
indicators.append(indicator)
return {
indicator.cancel()
}
}
}