mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 14:13:45 +00:00
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
33 lines
1.0 KiB
Swift
33 lines
1.0 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()
|
|
}
|
|
}
|