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.
 
 
 

38 lines
1.3 KiB

//
// 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<String, TableViewCellModel>]>.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<String, TableViewCellModel>] = []
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)
}
}