ErrorPresenter: Support onPresented for showErrorAlert(title:,message:)
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
@@ -6,7 +6,7 @@ import os.log
|
|||||||
|
|
||||||
class ErrorPresenter {
|
class ErrorPresenter {
|
||||||
static func showErrorAlert(error: WireGuardAppError, from sourceVC: UIViewController?,
|
static func showErrorAlert(error: WireGuardAppError, from sourceVC: UIViewController?,
|
||||||
onDismissal: (() -> Void)? = nil, onPresented: (() -> Void)? = nil) {
|
onPresented: (() -> Void)? = nil, onDismissal: (() -> Void)? = nil) {
|
||||||
guard let sourceVC = sourceVC else { return }
|
guard let sourceVC = sourceVC else { return }
|
||||||
guard let (title, message) = error.alertText() else { return }
|
guard let (title, message) = error.alertText() else { return }
|
||||||
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
|
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
|
||||||
@@ -18,7 +18,8 @@ class ErrorPresenter {
|
|||||||
sourceVC.present(alert, animated: true, completion: onPresented)
|
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?,
|
||||||
|
onPresented: (() -> Void)? = nil, onDismissal: (() -> Void)? = nil) {
|
||||||
guard let sourceVC = sourceVC else { return }
|
guard let sourceVC = sourceVC else { return }
|
||||||
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
|
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
|
||||||
onDismissal?()
|
onDismissal?()
|
||||||
@@ -26,6 +27,6 @@ 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user