On-Demand: Move detail text to TunnelViewModel
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
b7e5638681
commit
465c22f769
|
@ -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 {
|
func defaultActivateOnDemandOption() -> ActivateOnDemandOption {
|
||||||
return .useOnDemandOverWiFiOrCellular
|
return .useOnDemandOverWiFiOrCellular
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,26 +426,7 @@ class TunnelDetailTableViewActivateOnDemandCell: UITableViewCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(from activateOnDemandSetting: ActivateOnDemandSetting?) {
|
func update(from activateOnDemandSetting: ActivateOnDemandSetting?) {
|
||||||
let detailText: String
|
detailTextLabel?.text = TunnelViewModel.activateOnDemandDetailText(for: activateOnDemandSetting)
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func prepareForReuse() {
|
override func prepareForReuse() {
|
||||||
|
|
Loading…
Reference in New Issue