on-demand: iOS: Only n SSIDs / Except m SSIDs

This commit is contained in:
Roopesh Chander 2019-03-09 15:35:49 +05:30 committed by Jason A. Donenfeld
parent 0e04f5d337
commit a876386c05
4 changed files with 25 additions and 2 deletions

View File

@ -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";

View File

@ -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 {

View File

@ -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
}
}

View File

@ -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
}
}