// // NoticeViewModels.swift // Lookfit // // Created by lemo. on 2020/3/29. // Copyright © 2020 Sheldon. All rights reserved. // import UIKit class NoticeViewModels: ViewModel { /// 数据源 let datasource = BehaviorRelay<[SectionModel]>.init(value: []) /// 功能列表 let funcations: [[PushType]] = [[.all], [.qq, .wechat, .whatsapp, .messenger, .twitter, .linkedin, .instagram, .facebook, .line, .viber, .skype, .outlook,.others]] override init() { super.init() loadFuncation() } func loadFuncation() { var sections: [SectionModel] = [] funcations.forEach { (types) in var cellModels: [TableViewCellModel] = [] types.enumerated().forEach { (index, type) in let isBottomLine = index != types.count - 1 let isON = type.getSwitchState(currenValue: GlobalDeviceProfileModel.shareInstance.pushSetValue) let cellModel = TableViewCellModel(title: type.title, isSwitch: true, description: nil, isArrows: false, isOn: isON, image: nil, isBottomLine: isBottomLine, pushType: type) cellModels.append(cellModel) } sections.append(SectionModel(model: "", items: cellModels)) } datasource.accept(sections) } }