Animate toggle-switch (IOS-14)
This commit is contained in:
parent
0e964de0df
commit
b6a7126eb1
|
@ -128,16 +128,24 @@ extension GeneralSettingsViewController: UITableViewDelegate {
|
|||
switch section {
|
||||
case .appearance(let appearanceOption):
|
||||
viewModel.selectedAppearence = appearanceOption
|
||||
case .design(_):
|
||||
|
||||
break
|
||||
case .openLinksIn(let openLinksInOption):
|
||||
viewModel.selectedOpenLinks = openLinksInOption
|
||||
}
|
||||
|
||||
if let snapshot = tableViewDataSource?.snapshot() {
|
||||
tableViewDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
}
|
||||
case .design(let design):
|
||||
guard let cell = tableView.cellForRow(at: indexPath) as? GeneralSettingToggleTableViewCell else { return}
|
||||
|
||||
let newValue = (cell.toggle.isOn == false)
|
||||
cell.toggle.setOn(newValue, animated: true)
|
||||
|
||||
toggle(cell, setting: .design(design), isOn: newValue)
|
||||
case .openLinksIn(let openLinksInOption):
|
||||
viewModel.selectedOpenLinks = openLinksInOption
|
||||
|
||||
if let snapshot = tableViewDataSource?.snapshot() {
|
||||
tableViewDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
}
|
||||
}
|
||||
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
delegate?.save(self, setting: setting, viewModel: viewModel)
|
||||
|
@ -156,9 +164,6 @@ extension GeneralSettingsViewController: GeneralSettingToggleTableViewCellDelega
|
|||
}
|
||||
}
|
||||
|
||||
if let snapshot = tableViewDataSource?.snapshot() {
|
||||
tableViewDataSource?.applySnapshotUsingReloadData(snapshot)
|
||||
}
|
||||
delegate?.save(self, setting: self.setting, viewModel: viewModel)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue