Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
101
iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift
Normal file
101
iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
protocol BottomMenuInteractorProtocol: AnyObject {
|
||||
func close()
|
||||
func addPlace()
|
||||
func downloadMaps()
|
||||
func donate()
|
||||
func openHelp()
|
||||
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 = SettingsBridge.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 openHelp() {
|
||||
close()
|
||||
mapViewController?.openAbout()
|
||||
}
|
||||
|
||||
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() {
|
||||
close()
|
||||
let mapViewController = MapViewController.shared()!
|
||||
switch trackRecorder.recordingState {
|
||||
case .active:
|
||||
mapViewController.showTrackRecordingPlacePage()
|
||||
case .inactive:
|
||||
trackRecorder.start { result in
|
||||
switch result {
|
||||
case .success:
|
||||
mapViewController.showTrackRecordingPlacePage()
|
||||
case .failure:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue