on-demand: iOS: Update on-demand info shown in tunnel edit view
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
bd339e2876
commit
574d8433b3
|
@ -137,6 +137,13 @@ extension ActivateOnDemandViewModel {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fixSSIDOption() {
|
||||||
|
selectedSSIDs = uniquifiedNonEmptySelectedSSIDs()
|
||||||
|
if selectedSSIDs.isEmpty {
|
||||||
|
ssidOption = .anySSID
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension ActivateOnDemandViewModel {
|
private extension ActivateOnDemandViewModel {
|
||||||
|
|
|
@ -9,8 +9,13 @@ class ChevronCell: UITableViewCell {
|
||||||
set(value) { textLabel?.text = value }
|
set(value) { textLabel?.text = value }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var detailMessage: String {
|
||||||
|
get { return detailTextLabel?.text ?? "" }
|
||||||
|
set(value) { detailTextLabel?.text = value }
|
||||||
|
}
|
||||||
|
|
||||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||||
super.init(style: .default, reuseIdentifier: reuseIdentifier)
|
super.init(style: .value1, reuseIdentifier: reuseIdentifier)
|
||||||
accessoryType = .disclosureIndicator
|
accessoryType = .disclosureIndicator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -442,6 +442,7 @@ extension TunnelEditTableViewController {
|
||||||
} else {
|
} else {
|
||||||
let cell: ChevronCell = tableView.dequeueReusableCell(for: indexPath)
|
let cell: ChevronCell = tableView.dequeueReusableCell(for: indexPath)
|
||||||
cell.message = field.localizedUIString
|
cell.message = field.localizedUIString
|
||||||
|
cell.detailMessage = onDemandViewModel.ssidOption.localizedUIString
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,8 +501,14 @@ extension TunnelEditTableViewController {
|
||||||
|
|
||||||
extension TunnelEditTableViewController: SSIDOptionEditTableViewControllerDelegate {
|
extension TunnelEditTableViewController: SSIDOptionEditTableViewControllerDelegate {
|
||||||
func ssidOptionSaved(option: ActivateOnDemandViewModel.OnDemandSSIDOption, ssids: [String]) {
|
func ssidOptionSaved(option: ActivateOnDemandViewModel.OnDemandSSIDOption, ssids: [String]) {
|
||||||
let validSSIDs = ssids.filter { !$0.isEmpty }
|
onDemandViewModel.selectedSSIDs = ssids
|
||||||
onDemandViewModel.selectedSSIDs = validSSIDs
|
onDemandViewModel.ssidOption = option
|
||||||
onDemandViewModel.ssidOption = validSSIDs.isEmpty ? .anySSID : option
|
onDemandViewModel.fixSSIDOption()
|
||||||
|
if let onDemandSection = sections.firstIndex(where: { $0 == .onDemand }) {
|
||||||
|
if let ssidRowIndex = onDemandFields.firstIndex(of: .ssid) {
|
||||||
|
let indexPath = IndexPath(row: ssidRowIndex, section: onDemandSection)
|
||||||
|
tableView.reloadRows(at: [indexPath], with: .none)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue