mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-05 20:23:48 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
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
This commit is contained in:
86
iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift
Normal file
86
iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift
Normal file
@@ -0,0 +1,86 @@
|
||||
protocol BottomMenuInteractorProtocol: AnyObject {
|
||||
func close()
|
||||
func addPlace()
|
||||
func downloadMaps()
|
||||
func donate()
|
||||
func openSettings()
|
||||
func shareLocation(cell: BottomMenuItemCell)
|
||||
func toggleTrackRecording()
|
||||
}
|
||||
|
||||
@objc protocol BottomMenuDelegate {
|
||||
func actionDownloadMaps(_ mode: MWMMapDownloaderMode)
|
||||
func addPlace()
|
||||
func didFinishAddingPlace()
|
||||
}
|
||||
|
||||
class BottomMenuInteractor {
|
||||
weak var presenter: BottomMenuPresenterProtocol?
|
||||
private weak var viewController: UIViewController?
|
||||
private weak var mapViewController: MapViewController?
|
||||
private weak var delegate: BottomMenuDelegate?
|
||||
private weak var controlsManager: MWMMapViewControlsManager?
|
||||
|
||||
private let trackRecorder: TrackRecordingManager = .shared
|
||||
|
||||
init(viewController: UIViewController,
|
||||
mapViewController: MapViewController,
|
||||
controlsManager: MWMMapViewControlsManager,
|
||||
delegate: BottomMenuDelegate) {
|
||||
self.viewController = viewController
|
||||
self.mapViewController = mapViewController
|
||||
self.delegate = delegate
|
||||
self.controlsManager = controlsManager
|
||||
}
|
||||
}
|
||||
|
||||
extension BottomMenuInteractor: BottomMenuInteractorProtocol {
|
||||
func close() {
|
||||
guard let controlsManager = controlsManager else {
|
||||
fatalError()
|
||||
}
|
||||
controlsManager.menuState = controlsManager.menuRestoreState
|
||||
}
|
||||
|
||||
func addPlace() {
|
||||
delegate?.addPlace()
|
||||
}
|
||||
|
||||
func donate() {
|
||||
close()
|
||||
guard var url = Settings.donateUrl() else { return }
|
||||
if url == "https://organicmaps.app/donate/" {
|
||||
url = L("translated_om_site_url") + "donate/"
|
||||
}
|
||||
viewController?.openUrl(url, externally: true)
|
||||
}
|
||||
|
||||
func downloadMaps() {
|
||||
close()
|
||||
delegate?.actionDownloadMaps(.downloaded)
|
||||
}
|
||||
|
||||
func openSettings() {
|
||||
close()
|
||||
mapViewController?.openSettings()
|
||||
}
|
||||
|
||||
func shareLocation(cell: BottomMenuItemCell) {
|
||||
let lastLocation = LocationManager.lastLocation()
|
||||
guard let coordinates = lastLocation?.coordinate else {
|
||||
let alert = UIAlertController(title: L("unknown_current_position"), message: nil, preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: L("ok"), style: .default, handler: nil))
|
||||
viewController?.present(alert, animated: true, completion: nil)
|
||||
return;
|
||||
}
|
||||
guard let viewController = viewController else { return }
|
||||
let vc = ActivityViewController.share(forMyPosition: coordinates)
|
||||
vc.present(inParentViewController: viewController, anchorView: cell.anchorView)
|
||||
}
|
||||
|
||||
func toggleTrackRecording() {
|
||||
trackRecorder.processAction(trackRecorder.recordingState == .active ? .stop : .start) { [weak self] in
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user