mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 06:33:42 +00:00
1. add an new screen (layout) 2. add TR icon for the bottom tabbar 3. share current location from the TR PP 4. refactor TR manager to properly handle state updates and pass them to the LiveActivityManager and PlacePage 5. add init/update with TrackInfo/EleInfo methods to the PlacePageData and PlacePagePreviewData to update the PP state Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
89 lines
2.4 KiB
Swift
89 lines
2.4 KiB
Swift
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://www.comaps.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) {
|
|
guard let coordinates = LocationManager.lastLocation()?.coordinate else {
|
|
viewController?.present(UIAlertController.unknownCurrentPosition(), 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() {
|
|
switch trackRecorder.recordingState {
|
|
case .active:
|
|
break
|
|
case .inactive:
|
|
trackRecorder.processAction(.start)
|
|
}
|
|
close()
|
|
MapViewController.shared()?.showTrackRecordingPlacePage()
|
|
}
|
|
}
|