ErrorPresenter: showErrorAlert takes an onPresentated handler
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
a512216d85
commit
2f5e83cf99
|
@ -51,7 +51,8 @@ class ErrorPresenter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func showErrorAlert(error: Error, from sourceVC: UIViewController?, onDismissal: (() -> Void)? = nil) {
|
static func showErrorAlert(error: Error, from sourceVC: UIViewController?,
|
||||||
|
onDismissal: (() -> Void)? = nil, onPresented: (() -> Void)? = nil) {
|
||||||
guard let sourceVC = sourceVC else { return }
|
guard let sourceVC = sourceVC else { return }
|
||||||
guard let (title, message) = ErrorPresenter.errorMessage(for: error) else { return }
|
guard let (title, message) = ErrorPresenter.errorMessage(for: error) else { return }
|
||||||
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
|
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
|
||||||
|
@ -60,7 +61,7 @@ class ErrorPresenter {
|
||||||
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
||||||
alert.addAction(okAction)
|
alert.addAction(okAction)
|
||||||
|
|
||||||
sourceVC.present(alert, animated: true)
|
sourceVC.present(alert, animated: true, completion: onPresented)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func showErrorAlert(title: String, message: String, from sourceVC: UIViewController?, onDismissal: (() -> Void)? = nil) {
|
static func showErrorAlert(title: String, message: String, from sourceVC: UIViewController?, onDismissal: (() -> Void)? = nil) {
|
||||||
|
|
Loading…
Reference in New Issue