From b7f8f74b5698f120ce22c79c32ccfc6fdb37252f Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Sat, 9 Mar 2019 15:35:49 +0530 Subject: on-demand: iOS: Only n SSIDs / Except m SSIDs Signed-off-by: Roopesh Chander --- WireGuard/WireGuard/Base.lproj/Localizable.strings | 4 ++++ .../WireGuard/UI/ActivateOnDemandViewModel.swift | 19 +++++++++++++++++++ .../TunnelDetailTableViewController.swift | 2 +- .../TunnelEditTableViewController.swift | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/WireGuard/WireGuard/Base.lproj/Localizable.strings b/WireGuard/WireGuard/Base.lproj/Localizable.strings index de2a8c2..32b792f 100644 --- a/WireGuard/WireGuard/Base.lproj/Localizable.strings +++ b/WireGuard/WireGuard/Base.lproj/Localizable.strings @@ -89,6 +89,10 @@ "tunnelOnDemandAnySSID" = "Any SSID"; "tunnelOnDemandOnlySelectedSSIDs" = "Only selected SSIDs"; "tunnelOnDemandExceptSelectedSSIDs" = "Except selected SSIDs"; +"tunnelOnDemandOnlySSID (%d)" = "Only %d SSID"; +"tunnelOnDemandOnlySSIDs (%d)" = "Only %d SSIDs"; +"tunnelOnDemandExceptSSID (%d)" = "Except %d SSID"; +"tunnelOnDemandExceptSSIDs (%d)" = "Except %d SSIDs"; "tunnelOnDemandSSIDViewTitle" = "SSIDs"; "tunnelOnDemandSectionTitleSelectedSSIDs" = "SSIDs"; diff --git a/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift b/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift index 2f13f07..c7d0173 100644 --- a/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift +++ b/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift @@ -130,6 +130,25 @@ extension ActivateOnDemandViewModel { } } + var localizedSSIDDescription: String { + guard isWiFiInterfaceEnabled else { return "" } + switch ssidOption { + case .anySSID: return tr("tunnelOnDemandAnySSID") + case .onlySpecificSSIDs: + if selectedSSIDs.count == 1 { + return tr(format: "tunnelOnDemandOnlySSID (%d)", selectedSSIDs.count) + } else { + return tr(format: "tunnelOnDemandOnlySSIDs (%d)", selectedSSIDs.count) + } + case .exceptSpecificSSIDs: + if selectedSSIDs.count == 1 { + return tr(format: "tunnelOnDemandExceptSSID (%d)", selectedSSIDs.count) + } else { + return tr(format: "tunnelOnDemandExceptSSIDs (%d)", selectedSSIDs.count) + } + } + } + func fixSSIDOption() { selectedSSIDs = uniquifiedNonEmptySelectedSSIDs() if selectedSSIDs.isEmpty { diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift index abee818..32393a9 100644 --- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift @@ -423,7 +423,7 @@ extension TunnelDetailTableViewController { } else { let cell: ChevronCell = tableView.dequeueReusableCell(for: indexPath) cell.message = field.localizedUIString - cell.detailMessage = onDemandViewModel.ssidOption.localizedUIString + cell.detailMessage = onDemandViewModel.localizedSSIDDescription return cell } } diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift index e5f322a..943e7e5 100644 --- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift @@ -442,7 +442,7 @@ extension TunnelEditTableViewController { } else { let cell: ChevronCell = tableView.dequeueReusableCell(for: indexPath) cell.message = field.localizedUIString - cell.detailMessage = onDemandViewModel.ssidOption.localizedUIString + cell.detailMessage = onDemandViewModel.localizedSSIDDescription return cell } } -- cgit v1.2.3-59-g8ed1b