// // NotDisturbViewModel.swift // Lookfit // // Created by lemo. on 2020/3/29. // Copyright © 2020 Sheldon. All rights reserved. // import UIKit class NotDisturbViewModel: ViewModel { var dataVariable = BehaviorRelay<[MultipleSectionModel]>(value: []) var dataSource: [MultipleSectionModel] = [] var noDisturbModel: NoDisturbModel = NoDisturbModel() override init() { super.init() if let temp = GlobalDeviceProfileModel.shareInstance.noDisturbModel?.copy() as? NoDisturbModel { noDisturbModel = temp } loadData(model: noDisturbModel) } func loadData(model: NoDisturbModel) { let cellModel = TableViewCellModel(title: MultiLanguageKey.smartSwitch.localized, isSwitch: true, description: nil, isArrows: false, isOn: model.IsOpen, image: nil, isBottomLine: false) let mod1 = MultipleSectionModel.SettingSection(title: "", items: [.TableViewCellModel(cellModel: cellModel)]) let mod2 = MultipleSectionModel.DoubleTimePickerSection(title: "", items: [SectionItem.DoubleTimePicker(leftTitle: MultiLanguageKey.startTime.localized, rightTitle: MultiLanguageKey.endTime.localized, selectedItems: [model.StartTime, model.EndTime])]) dataSource.append(mod1) dataSource.append(mod2) dataVariable.accept(dataSource) } }