forked from organicmaps/organicmaps
[ios] bring back share my location
button
partly revert 43c46beb0f
(for the menu)
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
parent
ed45ee0ee5
commit
16b69f9a57
2 changed files with 24 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue