diff options
Diffstat (limited to 'Sources/WireGuardApp/UI/iOS/ErrorPresenter.swift')
-rw-r--r-- | Sources/WireGuardApp/UI/iOS/ErrorPresenter.swift | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Sources/WireGuardApp/UI/iOS/ErrorPresenter.swift b/Sources/WireGuardApp/UI/iOS/ErrorPresenter.swift new file mode 100644 index 0000000..7d134de --- /dev/null +++ b/Sources/WireGuardApp/UI/iOS/ErrorPresenter.swift @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved. + +import UIKit +import os.log + +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 } + + let okAction = UIAlertAction(title: "OK", style: .default) { _ in + onDismissal?() + } + let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) + alert.addAction(okAction) + + sourceVC.present(alert, animated: true, completion: onPresented) + } +} |