70 lines
1.9 KiB
Swift
70 lines
1.9 KiB
Swift
//
|
|
// ScheduleHistoryVC.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/26.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
import RxDataSources
|
|
import MJRefresh
|
|
|
|
class ScheduleHistoryVC: BaseViewController {
|
|
|
|
fileprivate var rootView: ScheduleHistoryView!
|
|
|
|
override func loadView() {
|
|
rootView = ScheduleHistoryView(frame: UIScreen.main.bounds)
|
|
view = rootView
|
|
}
|
|
|
|
private var viewModel = ScheduleHistoryViewModel()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
// Do any additional setup after loading the view.
|
|
bindViewModel()
|
|
requestData()
|
|
}
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
}
|
|
|
|
private func requestData() {
|
|
dl.showLoading()
|
|
viewModel.refresh()
|
|
}
|
|
|
|
private func bindViewModel() {
|
|
viewModel.output.sectionedItems
|
|
.bind(to: rootView.tableView.rx.items(dataSource: tableViewDataSource))
|
|
.disposed(by: disposeBag)
|
|
|
|
viewModel.output.refreshResult.subscribe(onNext: { [weak self] (status, isEmpty) in
|
|
guard let self = self else { return }
|
|
self.dl.dismiss()
|
|
self.rootView.tableView.refresh(status: status, isEmpty: isEmpty)
|
|
}).disposed(by: disposeBag)
|
|
|
|
rootView.tableView.rx.modelSelected(ScheduleModel.self)
|
|
.subscribe(viewModel.cellAction.inputs)
|
|
.disposed(by: disposeBag)
|
|
}
|
|
|
|
// MARK: - dataSource
|
|
lazy private var tableViewDataSource: RxTableViewSectionedReloadDataSource<ScheduleListSectionModel> = {
|
|
return RxTableViewSectionedReloadDataSource<ScheduleListSectionModel>(
|
|
configureCell: { (_, tableView, indexPath, model) in
|
|
let cell: ScheduleHistoryListCell = tableView.dequeueReusableCell(for: indexPath)
|
|
cell.configure(model)
|
|
return cell
|
|
}
|
|
)
|
|
}()
|
|
|
|
}
|