aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS')
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/SSIDOptionDetailTableViewController.swift48
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift42
2 files changed, 84 insertions, 6 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/SSIDOptionDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/SSIDOptionDetailTableViewController.swift
new file mode 100644
index 0000000..c1e0913
--- /dev/null
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/SSIDOptionDetailTableViewController.swift
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: MIT
+// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.
+
+import UIKit
+
+class SSIDOptionDetailTableViewController: UITableViewController {
+
+ let selectedSSIDs: [String]
+
+ init(title: String, ssids: [String]) {
+ selectedSSIDs = ssids
+ super.init(style: .grouped)
+ self.title = title
+ }
+
+ required init?(coder aDecoder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ tableView.estimatedRowHeight = 44
+ tableView.rowHeight = UITableView.automaticDimension
+
+ tableView.register(TextCell.self)
+ }
+}
+
+extension SSIDOptionDetailTableViewController {
+ override func numberOfSections(in tableView: UITableView) -> Int {
+ return 1
+ }
+
+ override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ return selectedSSIDs.count
+ }
+
+ override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+ return tr("tunnelOnDemandSectionTitleSelectedSSIDs")
+ }
+
+ override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+ let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
+ cell.message = selectedSSIDs[indexPath.row]
+ return cell
+ }
+}
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
index 4ed75a6..abee818 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
@@ -76,10 +76,10 @@ class TunnelDetailTableViewController: UITableViewController {
tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableView.automaticDimension
- tableView.allowsSelection = false
tableView.register(SwitchCell.self)
tableView.register(KeyValueCell.self)
tableView.register(ButtonCell.self)
+ tableView.register(ChevronCell.self)
restorationIdentifier = "TunnelDetailVC:\(tunnel.name)"
}
@@ -407,15 +407,26 @@ extension TunnelDetailTableViewController {
}
private func onDemandCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
- let cell: KeyValueCell = tableView.dequeueReusableCell(for: indexPath)
let field = TunnelDetailTableViewController.onDemandFields[indexPath.row]
- cell.key = field.localizedUIString
if field == .onDemand {
+ let cell: KeyValueCell = tableView.dequeueReusableCell(for: indexPath)
+ cell.key = field.localizedUIString
cell.value = onDemandViewModel.localizedInterfaceDescription
- } else if field == .ssid {
- cell.value = onDemandViewModel.ssidOption.localizedUIString
+ return cell
+ } else {
+ assert(field == .ssid)
+ if onDemandViewModel.ssidOption == .anySSID {
+ let cell: KeyValueCell = tableView.dequeueReusableCell(for: indexPath)
+ cell.key = field.localizedUIString
+ cell.value = onDemandViewModel.ssidOption.localizedUIString
+ return cell
+ } else {
+ let cell: ChevronCell = tableView.dequeueReusableCell(for: indexPath)
+ cell.message = field.localizedUIString
+ cell.detailMessage = onDemandViewModel.ssidOption.localizedUIString
+ return cell
+ }
}
- return cell
}
private func deleteConfigurationCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
@@ -438,3 +449,22 @@ extension TunnelDetailTableViewController {
}
}
+
+extension TunnelDetailTableViewController {
+ override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
+ if case .onDemand = sections[indexPath.section],
+ case .ssid = TunnelDetailTableViewController.onDemandFields[indexPath.row] {
+ return indexPath
+ }
+ return nil
+ }
+
+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+ if case .onDemand = sections[indexPath.section],
+ case .ssid = TunnelDetailTableViewController.onDemandFields[indexPath.row] {
+ let ssidDetailVC = SSIDOptionDetailTableViewController(title: onDemandViewModel.ssidOption.localizedUIString, ssids: onDemandViewModel.selectedSSIDs)
+ navigationController?.pushViewController(ssidDetailVC, animated: true)
+ }
+ tableView.deselectRow(at: indexPath, animated: true)
+ }
+}