SwitchCell nits
This commit is contained in:
parent
89fd494291
commit
00a7eabed2
|
@ -41,6 +41,7 @@ class SwitchCell: UITableViewCell {
|
||||||
|
|
||||||
override func prepareForReuse() {
|
override func prepareForReuse() {
|
||||||
super.prepareForReuse()
|
super.prepareForReuse()
|
||||||
|
onSwitchToggled = nil
|
||||||
isEnabled = true
|
isEnabled = true
|
||||||
message = ""
|
message = ""
|
||||||
isOn = false
|
isOn = false
|
||||||
|
|
|
@ -414,17 +414,16 @@ extension TunnelEditTableViewController {
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
guard isOn != self.activateOnDemandSetting.isActivateOnDemandEnabled else { return }
|
guard isOn != self.activateOnDemandSetting.isActivateOnDemandEnabled else { return }
|
||||||
|
|
||||||
|
self.activateOnDemandSetting.isActivateOnDemandEnabled = isOn
|
||||||
|
self.loadSections()
|
||||||
|
|
||||||
let indexPaths = (1 ..< 4).map { IndexPath(row: $0, section: indexPath.section) }
|
let indexPaths = (1 ..< 4).map { IndexPath(row: $0, section: indexPath.section) }
|
||||||
if isOn {
|
if isOn {
|
||||||
self.activateOnDemandSetting.isActivateOnDemandEnabled = true
|
|
||||||
if self.activateOnDemandSetting.activateOnDemandOption == .none {
|
if self.activateOnDemandSetting.activateOnDemandOption == .none {
|
||||||
self.activateOnDemandSetting.activateOnDemandOption = TunnelViewModel.defaultActivateOnDemandOption()
|
self.activateOnDemandSetting.activateOnDemandOption = TunnelViewModel.defaultActivateOnDemandOption()
|
||||||
}
|
}
|
||||||
self.loadSections()
|
|
||||||
self.tableView.insertRows(at: indexPaths, with: .fade)
|
self.tableView.insertRows(at: indexPaths, with: .fade)
|
||||||
} else {
|
} else {
|
||||||
self.activateOnDemandSetting.isActivateOnDemandEnabled = false
|
|
||||||
self.loadSections()
|
|
||||||
self.tableView.deleteRows(at: indexPaths, with: .fade)
|
self.tableView.deleteRows(at: indexPaths, with: .fade)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,7 +434,7 @@ extension TunnelEditTableViewController {
|
||||||
let selectedOption = activateOnDemandSetting.activateOnDemandOption
|
let selectedOption = activateOnDemandSetting.activateOnDemandOption
|
||||||
assert(selectedOption != .none)
|
assert(selectedOption != .none)
|
||||||
cell.message = TunnelViewModel.activateOnDemandOptionText(for: rowOption)
|
cell.message = TunnelViewModel.activateOnDemandOptionText(for: rowOption)
|
||||||
cell.isChecked = (selectedOption == rowOption)
|
cell.isChecked = selectedOption == rowOption
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue