diff options
author | Roopesh Chander <roop@roopc.net> | 2018-12-08 01:54:18 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-12-08 02:17:15 +0530 |
commit | 465c22f769eab09bc5404dddb301a48dfcb66f8e (patch) | |
tree | 0c46836c9a615a3cf0d120ccef51d9762e46ec86 /WireGuard/WireGuard/UI | |
parent | Plist: Handle crypto export (diff) | |
download | wireguard-apple-465c22f769eab09bc5404dddb301a48dfcb66f8e.tar.xz wireguard-apple-465c22f769eab09bc5404dddb301a48dfcb66f8e.zip |
On-Demand: Move detail text to TunnelViewModel
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI')
-rw-r--r-- | WireGuard/WireGuard/UI/TunnelViewModel.swift | 12 | ||||
-rw-r--r-- | WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift | 21 |
2 files changed, 13 insertions, 20 deletions
diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift index f237660..2a3f36b 100644 --- a/WireGuard/WireGuard/UI/TunnelViewModel.swift +++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift @@ -464,6 +464,18 @@ extension TunnelViewModel { } } + static func activateOnDemandDetailText(for activateOnDemandSetting: ActivateOnDemandSetting?) -> String { + if let activateOnDemandSetting = activateOnDemandSetting { + if (activateOnDemandSetting.isActivateOnDemandEnabled) { + return TunnelViewModel.activateOnDemandOptionText(for: activateOnDemandSetting.activateOnDemandOption) + } else { + return TunnelViewModel.activateOnDemandOptionText(for: .none) + } + } else { + return TunnelViewModel.activateOnDemandOptionText(for: .none) + } + } + func defaultActivateOnDemandOption() -> ActivateOnDemandOption { return .useOnDemandOverWiFiOrCellular } diff --git a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift index 5873f1d..a888924 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelDetailTableViewController.swift @@ -426,26 +426,7 @@ class TunnelDetailTableViewActivateOnDemandCell: UITableViewCell { } func update(from activateOnDemandSetting: ActivateOnDemandSetting?) { - let detailText: String - if let activateOnDemandSetting = activateOnDemandSetting { - if (activateOnDemandSetting.isActivateOnDemandEnabled) { - switch (activateOnDemandSetting.activateOnDemandOption) { - case .none: - detailText = "Off" - case .useOnDemandOverWiFiOrCellular: - detailText = "Wi-Fi or cellular" - case .useOnDemandOverWiFiOnly: - detailText = "Wi-Fi only" - case .useOnDemandOverCellularOnly: - detailText = "Cellular only" - } - } else { - detailText = "Off" - } - } else { - detailText = "Off" - } - detailTextLabel?.text = detailText + detailTextLabel?.text = TunnelViewModel.activateOnDemandDetailText(for: activateOnDemandSetting) } override func prepareForReuse() { |