2018-11-01 06:15:09 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2019-01-02 00:56:33 +00:00
|
|
|
// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.
|
2018-11-01 06:15:09 +00:00
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import os.log
|
|
|
|
|
2018-12-28 20:06:46 +00:00
|
|
|
class ErrorPresenter: ErrorPresenterProtocol {
|
|
|
|
static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?, onPresented: (() -> Void)?, onDismissal: (() -> Void)?) {
|
|
|
|
guard let sourceVC = sourceVC as? UIViewController else { return }
|
2018-12-13 04:26:04 +00:00
|
|
|
|
2018-12-12 21:33:14 +00:00
|
|
|
let okAction = UIAlertAction(title: "OK", style: .default) { _ in
|
2018-11-01 06:15:09 +00:00
|
|
|
onDismissal?()
|
|
|
|
}
|
|
|
|
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
|
|
|
alert.addAction(okAction)
|
|
|
|
|
2018-12-12 13:47:06 +00:00
|
|
|
sourceVC.present(alert, animated: true, completion: onPresented)
|
2018-11-01 06:15:09 +00:00
|
|
|
}
|
|
|
|
}
|