// // DrinkRemindViewModels.swift // FireBoltt // // Created by lemo. on 2020/3/29. // Copyright © 2020 Sheldon. All rights reserved. // import UIKit class DrinkRemindViewModels: ViewModel { var dataVariable = BehaviorRelay<[MultipleSectionModel]>(value: []) var dataSource: [MultipleSectionModel] = [] var drinkingModel: DrinkingModel = DrinkingModel() override init() { super.init() if let temp = GlobalDeviceProfileModel.shareInstance.drinkModel?.copy() as? DrinkingModel { drinkingModel = temp } loadData(model: drinkingModel) } func loadData(model: DrinkingModel) { dataSource.removeAll() let cellModel = TableViewCellModel(title: MultiLanguageKey_FB.smartSwitchFB.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_FB.startTimeFB.localized, rightTitle: MultiLanguageKey_FB.endTimeFB.localized, selectedItems: [model.StartTime, model.EndTime])]) let mod3 = MultipleSectionModel.SinglePickerSection(title: "", items: [SectionItem.SinglePicker(title: MultiLanguageKey_FB.frequencyFB.localized, selectedItem: model.Interval)]) let cycle = GlobalDeviceProfileModel.cycle(cycleStr: model.Cycle) let cellModel2 = TableViewCellModel(title: MultiLanguageKey_FB.repeatCycleFB.localized, isSwitch: false, description: cycle, isArrows: true, isOn: false, image: nil, isBottomLine: false) let mod4 = MultipleSectionModel.SettingSection(title: "", items: [.TableViewCellModel(cellModel: cellModel2)]) dataSource.append(mod1) dataSource.append(mod2) dataSource.append(mod3) dataSource.append(mod4) dataVariable.accept(dataSource) } }