You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
2.2 KiB
44 lines
2.2 KiB
// |
|
// SedentaryViewModels.swift |
|
// Lookfit |
|
// |
|
// Created by lemo. on 2020/3/30. |
|
// Copyright © 2020 Sheldon. All rights reserved. |
|
// |
|
|
|
import UIKit |
|
|
|
class SedentaryViewModels: ViewModel { |
|
|
|
var dataVariable = BehaviorRelay<[MultipleSectionModel]>(value: []) |
|
var dataSource: [MultipleSectionModel] = [] |
|
var sedentaryModel: SedentaryModel = SedentaryModel() |
|
|
|
override init() { |
|
super.init() |
|
if let temp = GlobalDeviceProfileModel.shareInstance.sedentaryModel?.copy() as? SedentaryModel { |
|
sedentaryModel = temp |
|
} |
|
loadData(model: sedentaryModel) |
|
} |
|
|
|
func loadData(model: SedentaryModel) { |
|
dataSource.removeAll() |
|
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 startTime = model.StartHour + ":00" |
|
let endTime = model.EndHour + ":00" |
|
let timeItems = [startTime, endTime] |
|
let mod2 = MultipleSectionModel.DoubleTimePickerSection(title: "", items: [SectionItem.DoubleTimePicker(leftTitle: MultiLanguageKey.startTime.localized, rightTitle: MultiLanguageKey.endTime.localized, selectedItems: timeItems)]) |
|
let mod3 = MultipleSectionModel.DoubleTimePickerSection(title: "", items: [SectionItem.DoubleTimePicker(leftTitle: MultiLanguageKey.frequency.localized, rightTitle: MultiLanguageKey.sedentaryThreshold.localized, selectedItems: [model.SittingTime, model.SittingThreshold])]) |
|
let cycle = GlobalDeviceProfileModel.cycle(cycleStr: model.Cycle) |
|
let cellModel2 = TableViewCellModel(title: MultiLanguageKey.repeatCycle.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) |
|
} |
|
|
|
}
|
|
|