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.
 
 
 

64 lines
2.1 KiB

//
// 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<CommonTableViewCell>(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<SectionModel<String, TableViewCellModel>>(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)
}
}