jsdw_ios/QuickLocation/Section/Schedule/ScheduleViewed/ScheduleViewedVC.swift

66 lines
1.8 KiB
Swift

//
// ScheduleViewedVC.swift
// QuickLocation
//
// Created by on 2026/6/26.
//
import UIKit
import RxSwift
import RxCocoa
import RxDataSources
import MJRefresh
class ScheduleViewedVC: BaseViewController {
fileprivate var rootView: ScheduleViewedView!
override func loadView() {
rootView = ScheduleViewedView(frame: UIScreen.main.bounds)
view = rootView
}
private var viewModel = ScheduleViewedViewModel()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
bindViewModel()
requestFollowList()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
private func requestFollowList() {
DLToast.showLoading()
UserService.followList().subscribe(onNext: { response in
DLToast.dismiss()
self.viewModel.loadViewedData(response.list)
}).disposed(by: disposeBag)
}
private func bindViewModel() {
viewModel.output.sectionedItems
.bind(to: rootView.tableView.rx.items(dataSource: tableViewDataSource))
.disposed(by: disposeBag)
rootView.tableView.rx.modelSelected(ViewedModel.self)
.subscribe(viewModel.cellAction.inputs)
.disposed(by: disposeBag)
}
// MARK: - dataSource
lazy private var tableViewDataSource: RxTableViewSectionedReloadDataSource<ViewedListSectionModel> = {
return RxTableViewSectionedReloadDataSource<ViewedListSectionModel>(
configureCell: { (_, tableView, indexPath, model) in
let cell: ScheduleViewedListCell = tableView.dequeueReusableCell(for: indexPath)
cell.configure(model)
return cell
}
)
}()
}