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.
59 lines
1.9 KiB
59 lines
1.9 KiB
// |
|
// noticeViewConrtoller.swift |
|
// Lookfit |
|
// |
|
// 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 NoticeViewConrtoller: TableViewController { |
|
|
|
override func viewDidLoad() { |
|
super.viewDidLoad() |
|
tableView.register(Resuable.tableViewCell) |
|
} |
|
|
|
override func makeUI() { |
|
super.makeUI() |
|
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? NoticeViewModel 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() { |
|
return; |
|
} |
|
guard let pushType = model.pushType else { return } |
|
BluetoothService.shared.setPushStatus(pushType: pushType, isOn: isOn) |
|
viewModel.loadFuncation() |
|
}) |
|
.disposed(by: cell.cellDisposeBag) |
|
return cell |
|
}) |
|
viewModel.datasource |
|
.bind(to: tableView.rx.items(dataSource: rxDataSource)) |
|
.disposed(by: rx.disposeBag) |
|
} |
|
}
|
|
|