62 lines
1.5 KiB
Swift
62 lines
1.5 KiB
Swift
//
|
|
// ScheduleHistoryVM.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/26.
|
|
//
|
|
|
|
import RxSwift
|
|
import RxCocoa
|
|
import RxDataSources
|
|
import MJRefresh
|
|
import ObjectMapper
|
|
|
|
class ScheduleHistoryViewModel: ViewModelType {
|
|
|
|
struct Input {}
|
|
|
|
struct Output {
|
|
var sectionedItems: Observable<[ScheduleListSectionModel]>
|
|
var refreshResult: Observable<RefreshResult>
|
|
var pagination: Observable<PaginationModel?>
|
|
var error: Observable<Error>
|
|
}
|
|
|
|
let input: Input
|
|
let output: Output
|
|
|
|
private var listService: ListService<ScheduleListResponse>
|
|
private let sectionedItems = PublishSubject<[ScheduleListSectionModel]>()
|
|
|
|
var refresh: MJRefreshComponentAction {
|
|
return {
|
|
self.listService.request.onNext(.refresh)
|
|
}
|
|
}
|
|
var loadMore: MJRefreshComponentAction {
|
|
return {
|
|
self.listService.request.onNext(.more)
|
|
}
|
|
}
|
|
|
|
lazy var cellAction: Action<ScheduleModel, Void> = { this in
|
|
return Action { model in
|
|
AppRouter.push(Route.itineraryDetail, userInfo: ["scheduleJson": model.toJSON()])
|
|
return .empty()
|
|
}
|
|
}(self)
|
|
|
|
// MARK: - init
|
|
init() {
|
|
listService = ItineraryService.query(history: true)
|
|
|
|
input = Input()
|
|
output = Output(
|
|
sectionedItems: listService.animatableSectionedItems,
|
|
refreshResult: listService.refreshResult,
|
|
pagination: listService.pagination,
|
|
error: listService.error
|
|
)
|
|
}
|
|
}
|