aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/ViewController
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS/ViewController')
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift19
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift19
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift17
3 files changed, 8 insertions, 47 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 {
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
index 7d360d1..6452bfb 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
@@ -311,7 +311,9 @@ extension TunnelEditTableViewController {
cell.hasDestructiveAction = true
cell.onTapped = { [weak self, weak peerData] in
guard let self = self, let peerData = peerData else { return }
- self.showConfirmationAlert(message: tr("deletePeerConfirmationAlertMessage"), buttonTitle: tr("deletePeerConfirmationAlertButtonTitle"), from: cell) { [weak self] in
+ ConfirmationAlertPresenter.showConfirmationAlert(message: tr("deletePeerConfirmationAlertMessage"),
+ buttonTitle: tr("deletePeerConfirmationAlertButtonTitle"),
+ from: cell, presentingVC: self) { [weak self] in
guard let self = self else { return }
let removedSectionIndices = self.deletePeer(peer: peerData)
let shouldShowExcludePrivateIPs = (self.tunnelViewModel.peersData.count == 1 && self.tunnelViewModel.peersData[0].shouldAllowExcludePrivateIPsControl)
@@ -461,21 +463,6 @@ extension TunnelEditTableViewController {
loadSections()
return IndexSet(integer: interfaceFieldsBySection.count + peer.index)
}
-
- 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)
- }
}
extension TunnelEditTableViewController {
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
index c09bb34..d54d7a1 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelsListTableViewController.swift
@@ -238,7 +238,8 @@ class TunnelsListTableViewController: UIViewController {
tr(format: "deleteTunnelConfirmationAlertButtonMessage (%d)", selectedTunnels.count) :
tr(format: "deleteTunnelsConfirmationAlertButtonMessage (%d)", selectedTunnels.count)
let title = tr("deleteTunnelsConfirmationAlertButtonTitle")
- self.showConfirmationAlert(message: message, buttonTitle: title, from: sender) { [weak self] in
+ ConfirmationAlertPresenter.showConfirmationAlert(message: message, buttonTitle: title,
+ from: sender, presentingVC: self) { [weak self] in
self?.tunnelsManager?.removeMultiple(tunnels: selectedTunnels) { [weak self] error in
guard let self = self else { return }
if let error = error {
@@ -250,20 +251,6 @@ class TunnelsListTableViewController: UIViewController {
}
}
}
-
- func showConfirmationAlert(message: String, buttonTitle: String, from barButtonItem: UIBarButtonItem, 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?.barButtonItem = barButtonItem
-
- present(alert, animated: true, completion: nil)
- }
}
extension TunnelsListTableViewController: UIDocumentPickerDelegate {