From 0f64927f7d995d32b2e3c4fa120560d2d2cc09d1 Mon Sep 17 00:00:00 2001 From: David Martinez <47610359+dvdmrtnz@users.noreply.github.com> Date: Sat, 23 Jul 2022 16:03:09 +0200 Subject: [PATCH] [ios] Add link to email in placepage Signed-off-by: David Martinez <47610359+dvdmrtnz@users.noreply.github.com> --- .../CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h | 1 + .../CoreApi/PlacePageData/Common/PlacePageInfoData.mm | 1 + iphone/Maps/UI/PlacePage/PlacePageInteractor.swift | 2 +- .../UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm | 4 ++++ .../PlacePage/PlacePageManager/MWMPlacePageManagerHelper.h | 1 + .../PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm | 5 +++++ 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h index deb6ae0ad7..8a13ab875b 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.h @@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly, nullable) NSString *twitter; @property(nonatomic, readonly, nullable) NSString *vk; @property(nonatomic, readonly, nullable) NSString *email; +@property(nonatomic, readonly, nullable) NSURL *emailUrl; @property(nonatomic, readonly, nullable) NSString *cuisine; @property(nonatomic, readonly, nullable) NSString *ppOperator; @property(nonatomic, readonly, nullable) NSString *address; diff --git a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm index 95a28d1b1e..387c4552fc 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/Common/PlacePageInfoData.mm @@ -40,6 +40,7 @@ using namespace osm; break; case Props::Email: _email = ToNSString(rawData.GetEmail()); + _emailUrl = [NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@", _email]]; break; case Props::ContactFacebook: _facebook = ToNSString(rawData.GetFacebookPage()); diff --git a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift index 05382bf82f..04f60d5ec8 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageInteractor.swift @@ -50,7 +50,7 @@ extension PlacePageInteractor: PlacePageInfoViewControllerDelegate { } func didPressEmail() { - + MWMPlacePageManagerHelper.openEmail(placePageData) } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm index dd5eba87c5..a25567ddf0 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManager.mm @@ -245,6 +245,10 @@ using namespace storage; [self.ownerViewController openUrl:[NSString stringWithFormat:@"https://vk.com/%@", data.infoData.vk]]; } +- (void)openEmail:(PlacePageData *)data { + [UIApplication.sharedApplication openURL:data.infoData.emailUrl options:@{} completionHandler:nil]; +} + - (void)openElevationDifficultPopup:(PlacePageData *)data { auto difficultyPopup = [ElevationDetailsBuilder buildWithData:data]; [[MapViewController sharedController] presentViewController:difficultyPopup animated:YES completion:nil]; diff --git a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.h b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.h index f99962b476..23e2370f9c 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.h +++ b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.h @@ -8,6 +8,7 @@ + (void)addBusiness; + (void)addPlace:(CLLocationCoordinate2D)coordinate; + (void)openWebsite:(PlacePageData *)data; ++ (void)openEmail:(PlacePageData *)data; + (void)openFacebook:(PlacePageData *)data; + (void)openInstagram:(PlacePageData *)data; + (void)openTwitter:(PlacePageData *)data; diff --git a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm index 428686f80c..f970bf5051 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageManager/MWMPlacePageManagerHelper.mm @@ -15,6 +15,7 @@ - (void)addBusiness; - (void)addPlace:(CLLocationCoordinate2D)coordinate; - (void)openWebsite:(PlacePageData *)data; +- (void)openEmail:(PlacePageData *)data; - (void)openFacebook:(PlacePageData *)data; - (void)openInstagram:(PlacePageData *)data; - (void)openTwitter:(PlacePageData *)data; @@ -67,6 +68,10 @@ [[MWMMapViewControlsManager manager].placePageManager openWebsite:data]; } ++ (void)openEmail:(PlacePageData *)data { + [[MWMMapViewControlsManager manager].placePageManager openEmail:data]; +} + + (void)openFacebook:(PlacePageData *)data { [[MWMMapViewControlsManager manager].placePageManager openFacebook:data]; }