aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/ErrorPresenterProtocol.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-29 01:36:46 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:29 +0530
commit6a27626fc003399b1f542b7ef64ea838001375dc (patch)
tree97306ad99b7c4fdd429a464068d3caa457f3e47e /WireGuard/WireGuard/UI/ErrorPresenterProtocol.swift
parentmacOS: Add tunnel management menu items (diff)
downloadwireguard-apple-6a27626fc003399b1f542b7ef64ea838001375dc.tar.xz
wireguard-apple-6a27626fc003399b1f542b7ef64ea838001375dc.zip
iOS: Refactor importFromFile
So that it can be used in macOS as well Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/ErrorPresenterProtocol.swift')
-rw-r--r--WireGuard/WireGuard/UI/ErrorPresenterProtocol.swift25
1 files changed, 25 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/ErrorPresenterProtocol.swift b/WireGuard/WireGuard/UI/ErrorPresenterProtocol.swift
new file mode 100644
index 0000000..37e567c
--- /dev/null
+++ b/WireGuard/WireGuard/UI/ErrorPresenterProtocol.swift
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: MIT
+// Copyright © 2018 WireGuard LLC. All Rights Reserved.
+
+protocol ErrorPresenterProtocol {
+ static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?, onPresented: (() -> Void)?, onDismissal: (() -> Void)?)
+}
+
+extension ErrorPresenterProtocol {
+ static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?, onPresented: (() -> Void)?) {
+ showErrorAlert(title: title, message: message, from: sourceVC, onPresented: onPresented, onDismissal: nil)
+ }
+
+ static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?, onDismissal: (() -> Void)?) {
+ showErrorAlert(title: title, message: message, from: sourceVC, onPresented: nil, onDismissal: onDismissal)
+ }
+
+ static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?) {
+ showErrorAlert(title: title, message: message, from: sourceVC, onPresented: nil, onDismissal: nil)
+ }
+
+ static func showErrorAlert(error: WireGuardAppError, from sourceVC: AnyObject?, onPresented: (() -> Void)? = nil, onDismissal: (() -> Void)? = nil) {
+ let (title, message) = error.alertText
+ showErrorAlert(title: title, message: message, from: sourceVC, onPresented: onPresented, onDismissal: onDismissal)
+ }
+}