diff --git a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift index 706d66a71e..ac05c2e465 100644 --- a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift +++ b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuInteractor.swift @@ -4,6 +4,7 @@ protocol BottomMenuInteractorProtocol: AnyObject { func downloadMaps() func donate() func openSettings() + func shareLocation(cell: BottomMenuItemCell) } @objc protocol BottomMenuDelegate { @@ -60,4 +61,17 @@ extension BottomMenuInteractor: BottomMenuInteractorProtocol { close() mapViewController?.performSegue(withIdentifier: "Map2Settings", sender: nil) } + + 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) + } } diff --git a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift index be87f1c2aa..81447c0281 100644 --- a/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift +++ b/iphone/Maps/UI/BottomMenu/Menu/BottomMenuPresenter.swift @@ -8,6 +8,7 @@ class BottomMenuPresenter: NSObject { case downloadMaps case donate case settings + case share } enum Sections: Int { case layers @@ -79,6 +80,11 @@ extension BottomMenuPresenter { title: L("settings"), badgeCount: 0, enabled: true) + case .share: + cell.configure(imageName: "ic_menu_share", + title: L("share_my_location"), + badgeCount: 0, + enabled: true) } return cell } @@ -109,6 +115,10 @@ extension BottomMenuPresenter { interactor.donate() case .settings: interactor.openSettings() + case .share: + if let cell = tableView.cellForRow(at: indexPath) as? BottomMenuItemCell { + interactor.shareLocation(cell: cell) + } } } }