// // NoticeViewConrtollers.swift // FireBoltt // // Created by lemo. on 2020/3/29. // Copyright © 2020 Sheldon. All rights reserved. // import UIKit fileprivate enum Resuable { static let tableViewCell = ReusableCell(nibName: "CommonTableViewCell") } class NoticeViewConrtollers: TableViewController { override func viewDidLoad() { super.viewDidLoad() tableView.register(Resuable.tableViewCell) } override func makeUI() { super.makeUI() if #available(iOS 13.0, *) { tableViewStyle = .insetGrouped } else { // Fallback on earlier versions tableViewStyle = .grouped } tableView.backgroundColor = kHexColor(0xFAFAFA) view.addSubview(tableView) layoutUI() } func layoutUI() { tableView.snp.makeConstraints { (make) in make.edges.equalToSuperview() } } override func bindViewModel() { guard let viewModel = viewModel as? NoticeViewModels else { return } let rxDataSource = RxTableViewSectionedReloadDataSource>(configureCell: { (_ , tv, indexPath, model) -> UITableViewCell in let cell: CommonTableViewCell = tv.dequeue(Resuable.tableViewCell, for: indexPath) cell.bindViewModel(model: model) // CELL上开关时间处理 cell.rightSwitch.rx.isOn .skip(1) .subscribe(onNext: { (isOn) in if !BluetoothService.shared.checkBleCmdEnable(isShow: true) { return; } guard let pushType = model.pushType else { return } BluetoothService.shared.setPushStatus(pushType: pushType, isOn: isOn) viewModel.fbloadFuncation() }) .disposed(by: cell.cellDisposeBag) return cell }) viewModel.datasource .bind(to: tableView.rx.items(dataSource: rxDataSource)) .disposed(by: rx.disposeBag) } }