diff options
author | Roopesh Chander <roop@roopc.net> | 2019-03-19 01:24:06 +0530 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-18 14:54:05 -0600 |
commit | fc163fc9ff8e6408cfe262d758c402aada920cc1 (patch) | |
tree | 237a5a93e9966919b2a8adc8fe2590f0f0ba0791 /WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift | |
parent | iOS: Tunnels list: Ability to remove multiple tunnels at a time (diff) | |
download | wireguard-apple-fc163fc9ff8e6408cfe262d758c402aada920cc1.tar.xz wireguard-apple-fc163fc9ff8e6408cfe262d758c402aada920cc1.zip |
iOS: Consolidate all showConfirmationAlert()s into one place
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift')
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift index f198e06..b2dca83 100644 --- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift @@ -125,21 +125,6 @@ class TunnelDetailTableViewController: UITableViewController { } } - func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView, onConfirmed: @escaping (() -> Void)) { - let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { _ in - onConfirmed() - } - let cancelAction = UIAlertAction(title: tr("actionCancel"), style: .cancel) - let alert = UIAlertController(title: "", message: message, preferredStyle: .actionSheet) - alert.addAction(destroyAction) - alert.addAction(cancelAction) - - alert.popoverPresentationController?.sourceView = sourceView - alert.popoverPresentationController?.sourceRect = sourceView.bounds - - present(alert, animated: true, completion: nil) - } - func startUpdatingRuntimeConfiguration() { reloadRuntimeConfiguration() reloadRuntimeConfigurationTimer?.invalidate() @@ -435,7 +420,9 @@ extension TunnelDetailTableViewController { cell.hasDestructiveAction = true cell.onTapped = { [weak self] in guard let self = self else { return } - self.showConfirmationAlert(message: tr("deleteTunnelConfirmationAlertMessage"), buttonTitle: tr("deleteTunnelConfirmationAlertButtonTitle"), from: cell) { [weak self] in + ConfirmationAlertPresenter.showConfirmationAlert(message: tr("deleteTunnelConfirmationAlertMessage"), + buttonTitle: tr("deleteTunnelConfirmationAlertButtonTitle"), + from: cell, presentingVC: self) { [weak self] in guard let self = self else { return } self.tunnelsManager.remove(tunnel: self.tunnel) { error in if error != nil { |