diff options
author | Roopesh Chander <roop@roopc.net> | 2018-11-01 23:04:56 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-11-01 23:45:48 +0530 |
commit | 55cf6e61816b5a2358b0f0ce08d5bf20cf407251 (patch) | |
tree | ccc2855af8dee1f142e9c7bc9a7a1185f9be2681 /WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift | |
parent | Global: fix up strings (diff) | |
download | wireguard-apple-55cf6e61816b5a2358b0f0ce08d5bf20cf407251.tar.xz wireguard-apple-55cf6e61816b5a2358b0f0ce08d5bf20cf407251.zip |
Tunnels list: Swipe left to delete
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift index d142ea4..67ed4f5 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift @@ -273,6 +273,23 @@ extension TunnelsListTableViewController { let tunnelDetailNC = UINavigationController(rootViewController: tunnelDetailVC) showDetailViewController(tunnelDetailNC, sender: self) // Shall get propagated up to the split-vc } + + override func tableView(_ tableView: UITableView, + trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { + let deleteAction = UIContextualAction(style: .destructive, title: "Delete", handler: { [weak self] (_, _, completionHandler) in + guard let tunnelsManager = self?.tunnelsManager else { return } + let tunnel = tunnelsManager.tunnel(at: indexPath.row) + tunnelsManager.remove(tunnel: tunnel, completionHandler: { (error) in + if (error != nil) { + ErrorPresenter.showErrorAlert(error: error!, from: self) + completionHandler(false) + } else { + completionHandler(true) + } + }) + }) + return UISwipeActionsConfiguration(actions: [deleteAction]) + } } // MARK: TunnelsManagerDelegate |