co-maps/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewModel.swift
2025-11-22 13:58:55 +01:00

32 lines
1 KiB
Swift

@objc(MWMRouteManagerViewModel)
final class RouteManagerViewModel: NSObject, RouteManagerViewModelProtocol {
var routePoints: [MWMRoutePoint] { return MWMRouter.points() }
var refreshControlsCallback: (() -> Void)!
var reloadCallback: (() -> Void)!
func startTransaction() { MWMRouter.openRouteManagerTransaction() }
func finishTransaction() {
MWMRouter.applyRouteManagerTransaction()
MWMRouter.rebuild(withBestRouter: false)
}
func cancelTransaction() { MWMRouter.cancelRouteManagerTransaction() }
func addLocationPoint() {
MWMRouter.addPoint(MWMRoutePoint(lastLocationAndType: .start, intermediateIndex: 0))
MWMRouter.updatePreviewMode()
refreshControlsCallback()
}
func movePoint(at index: Int, to newIndex: Int) {
MWMRouter.movePoint(at: index, to: newIndex)
MWMRouter.updatePreviewMode()
refreshControlsCallback()
}
func deletePoint(at index: Int) {
MWMRouter.removePoint(routePoints[index])
MWMRouter.updatePreviewMode()
refreshControlsCallback()
reloadCallback()
}
}