summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-04-01 13:41:49 +0200
committerAndrej Mihajlov <and@mullvad.net>2020-04-01 17:16:01 +0200
commit5fecd6dd09d2a62fcb46abaa242b1d89a3acf28c (patch)
tree7ca70047b96ecac022426b2198e785c2e68031da /ios
parentb830a97229f0e93061fec41d6647ccc651ce5b59 (diff)
downloadmullvadvpn-5fecd6dd09d2a62fcb46abaa242b1d89a3acf28c.tar.xz
mullvadvpn-5fecd6dd09d2a62fcb46abaa242b1d89a3acf28c.zip
Add log out confirmation dialog
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadVPN/AccountViewController.swift44
1 files changed, 42 insertions, 2 deletions
diff --git a/ios/MullvadVPN/AccountViewController.swift b/ios/MullvadVPN/AccountViewController.swift
index dcd631d275..34a5b0e4d3 100644
--- a/ios/MullvadVPN/AccountViewController.swift
+++ b/ios/MullvadVPN/AccountViewController.swift
@@ -153,9 +153,39 @@ class AccountViewController: UIViewController {
present(alertController, animated: true)
}
- // MARK: - Actions
+ private func showLogoutConfirmation(completion: @escaping (Bool) -> Void, animated: Bool) {
+ let message = NSLocalizedString(
+ "Are you sure you want to log out?\n\nThis will erase the account number from this device. It is not possible for us to recover it for you. Make sure you have your account number saved somewhere, to be able to log back in.",
+ comment: "Alert message in log out confirmation")
- @IBAction func doLogout() {
+ let alertController = UIAlertController(
+ title: NSLocalizedString("Log out", comment: "Alert title in log out confirmation"),
+ message: message,
+ preferredStyle: .alert
+ )
+
+ alertController.addAction(
+ UIAlertAction(
+ title: NSLocalizedString("Cancel", comment: "Log out confirmation action"),
+ style: .cancel,
+ handler: { (alertAction) in
+ completion(false)
+ })
+ )
+
+ alertController.addAction(
+ UIAlertAction(
+ title: NSLocalizedString("Log out", comment: "Log out confirmation action"),
+ style: .destructive,
+ handler: { (alertAction) in
+ completion(true)
+ })
+ )
+
+ present(alertController, animated: animated)
+ }
+
+ private func confirmLogout() {
let message = NSLocalizedString("Logging out. Please wait...",
comment: "A modal message displayed during log out")
@@ -181,6 +211,16 @@ class AccountViewController: UIViewController {
}
}
+ // MARK: - Actions
+
+ @IBAction func doLogout() {
+ showLogoutConfirmation(completion: { (confirmed) in
+ if confirmed {
+ self.confirmLogout()
+ }
+ }, animated: true)
+ }
+
@IBAction func copyAccountToken() {
UIPasteboard.general.string = Account.shared.token