diff --git a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift index 1626422fa7..fa6d007f8b 100644 --- a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift +++ b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift @@ -1,6 +1,6 @@ import SafariServices -class BookmarksSubscriptionViewController: MWMViewController { +@objc class BookmarksSubscriptionViewController: MWMViewController { @IBOutlet private var annualView: UIView! @IBOutlet private var monthlyView: UIView! @IBOutlet private var gradientView: GradientView! @@ -15,8 +15,8 @@ class BookmarksSubscriptionViewController: MWMViewController { private var annualSubscription: ISubscription? private var selectedSubscription: ISubscription? - var onSubscribe: MWMVoidBlock? - var onCancel: MWMVoidBlock? + @objc var onSubscribe: MWMVoidBlock? + @objc var onCancel: MWMVoidBlock? override var supportedInterfaceOrientations: UIInterfaceOrientationMask { get { return [.portrait] } diff --git a/iphone/Maps/Bookmarks/Catalog/Dialogs/BookmarksSubscriptionGoToCatalogViewController.swift b/iphone/Maps/Bookmarks/Catalog/Dialogs/BookmarksSubscriptionGoToCatalogViewController.swift new file mode 100644 index 0000000000..e10f087e26 --- /dev/null +++ b/iphone/Maps/Bookmarks/Catalog/Dialogs/BookmarksSubscriptionGoToCatalogViewController.swift @@ -0,0 +1,25 @@ +@objc class BookmarksSubscriptionGoToCatalogViewController: UIViewController { + private let transitioning = FadeTransitioning() + private let onOk: MWMVoidBlock + private let onCancel: MWMVoidBlock + + @objc init(onOk: @escaping MWMVoidBlock, onCancel: @escaping MWMVoidBlock) { + self.onOk = onOk + self.onCancel = onCancel + super.init(nibName: nil, bundle: nil) + transitioningDelegate = transitioning + modalPresentationStyle = .custom + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @IBAction func onOk(_ sender: UIButton) { + onOk() + } + + @IBAction func onCancel(_ sender: UIButton) { + onCancel() + } +} diff --git a/iphone/Maps/Bookmarks/Catalog/Dialogs/BookmarksSubscriptionGoToCatalogViewController.xib b/iphone/Maps/Bookmarks/Catalog/Dialogs/BookmarksSubscriptionGoToCatalogViewController.xib new file mode 100644 index 0000000000..5724d0429a --- /dev/null +++ b/iphone/Maps/Bookmarks/Catalog/Dialogs/BookmarksSubscriptionGoToCatalogViewController.xib @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index 238ff02a9b..62b5408923 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -35,6 +35,7 @@ extern NSString * const kAlohalyticsTapEventKey; @property(nonatomic) MWMSideButtons * sideButtons; @property(nonatomic) MWMTrafficButtonViewController * trafficButton; +@property(nonatomic) UIButton * crownButton; @property(nonatomic) MWMBottomMenuViewController * menuController; @property(nonatomic) id placePageManager; @property(nonatomic) MWMNavigationDashboardManager * navigationManager; @@ -64,6 +65,13 @@ extern NSString * const kAlohalyticsTapEventKey; self.trafficButtonHidden = NO; self.isDirectionViewHidden = YES; self.menuRestoreState = MWMBottomMenuStateInactive; + if ([MWMFrameworkHelper shouldShowCrown]) { + [controller.controlsView addSubview:self.crownButton]; + self.crownButton.translatesAutoresizingMaskIntoConstraints = NO; + [NSLayoutConstraint activateConstraints: + @[[self.crownButton.leftAnchor constraintEqualToAnchor:self.trafficButton.view.leftAnchor constant:-4], + [self.crownButton.topAnchor constraintEqualToAnchor:self.sideButtons.view.topAnchor]]]; + } return self; } @@ -290,8 +298,42 @@ extern NSString * const kAlohalyticsTapEventKey; self.trafficButtonHidden = NO; } +- (void)onCrown:(UIButton *)sender { + BookmarksSubscriptionViewController *controller = [[BookmarksSubscriptionViewController alloc] init]; + controller.onSubscribe = ^{ + MapViewController *mapViewController = self.ownerController; + [mapViewController dismissViewControllerAnimated:YES completion:nil]; + BookmarksSubscriptionGoToCatalogViewController *successDialog = + [[BookmarksSubscriptionGoToCatalogViewController alloc] initOnOk:^{ + [mapViewController dismissViewControllerAnimated:YES completion:nil]; + [mapViewController openCatalogAnimated:YES utm:MWMUTMNone]; + } onCancel:^{ + [mapViewController dismissViewControllerAnimated:YES completion:nil]; + }]; + [mapViewController presentViewController:successDialog animated:YES completion:nil]; + }; + + controller.onCancel = ^{ + [self.ownerController dismissViewControllerAnimated:YES completion:nil]; + }; + + [self.ownerController presentViewController:controller animated:YES completion:^{ + self.crownButton.hidden = YES; + }]; + [MWMEye crownClicked]; +} + #pragma mark - Properties +- (UIButton *)crownButton { + if (!_crownButton) { + _crownButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_crownButton setImage:[UIImage imageNamed:@"bookmarksSubscriptionPromo"] forState:UIControlStateNormal]; + [_crownButton addTarget:self action:@selector(onCrown:) forControlEvents:UIControlEventTouchUpInside]; + } + return _crownButton; +} + - (MWMSideButtons *)sideButtons { if (!_sideButtons) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h index 3e1c82ca7e..6243fdca6c 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.h @@ -6,6 +6,7 @@ @property (nonatomic) BOOL zoomHidden; @property (nonatomic) BOOL hidden; +@property (nonatomic, readonly) UIView *view; - (instancetype)init __attribute__((unavailable("init is not available"))); - (instancetype)initWithParentView:(UIView *)view; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm index db2acf7440..6f4f0f5c8d 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtons.mm @@ -40,6 +40,10 @@ NSString * const kMWMSideButtonsViewNibName = @"MWMSideButtonsView"; @implementation MWMSideButtons +- (UIView *)view { + return self.sideView; +} + + (MWMSideButtons *)buttons { return [MWMMapViewControlsManager manager].sideButtons; } - (instancetype)initWithParentView:(UIView *)view { diff --git a/iphone/Maps/Core/Framework/MWMFrameworkHelper.h b/iphone/Maps/Core/Framework/MWMFrameworkHelper.h index ddc26745a5..f0d7adc4bb 100644 --- a/iphone/Maps/Core/Framework/MWMFrameworkHelper.h +++ b/iphone/Maps/Core/Framework/MWMFrameworkHelper.h @@ -36,4 +36,6 @@ NS_SWIFT_NAME(FrameworkHelper) + (void)rotateMap:(double)azimuth animated:(BOOL)isAnimated; + (void)updatePositionArrowOffset:(BOOL)useDefault offset:(int)offsetY; ++ (BOOL)shouldShowCrown; + @end diff --git a/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm b/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm index 486e9e0317..87b8aadfcd 100644 --- a/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm +++ b/iphone/Maps/Core/Framework/MWMFrameworkHelper.mm @@ -15,6 +15,7 @@ extern NSString * const kAlohalyticsTapEventKey; #include "base/sunrise_sunset.hpp" +#include "map/crown.hpp" @implementation MWMFrameworkHelper @@ -184,4 +185,8 @@ extern NSString * const kAlohalyticsTapEventKey; GetFramework().UpdateMyPositionRoutingOffset(useDefault, offsetY); } ++ (BOOL)shouldShowCrown { + return crown::NeedToShow(GetFramework().GetPurchase()); +} + @end diff --git a/iphone/Maps/Core/Metrics/MWMEye.h b/iphone/Maps/Core/Metrics/MWMEye.h index fbfac51ee1..db442b8f7f 100644 --- a/iphone/Maps/Core/Metrics/MWMEye.h +++ b/iphone/Maps/Core/Metrics/MWMEye.h @@ -35,5 +35,6 @@ typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent) + (void)discoveryItemClickedWithEvent:(MWMEyeDiscoveryEvent)event; + (void)transitionToBookingWithPos:(CGPoint)pos; + (void)promoAfterBookingShownWithCityId:(NSString *)cityId; ++ (void)crownClicked; @end diff --git a/iphone/Maps/Core/Metrics/MWMEye.mm b/iphone/Maps/Core/Metrics/MWMEye.mm index 0224cca9cc..eb72eb89e6 100644 --- a/iphone/Maps/Core/Metrics/MWMEye.mm +++ b/iphone/Maps/Core/Metrics/MWMEye.mm @@ -45,4 +45,9 @@ { eye::Eye::Event::PromoAfterBookingShown(cityId.UTF8String); } + ++ (void)crownClicked { + eye::Eye::Event::CrownClicked(); +} + @end diff --git a/iphone/Maps/Images.xcassets/BookmarksSubscription/bookmarksSubscriptionPromo.imageset/ FAB _ 48px - Blue.pdf b/iphone/Maps/Images.xcassets/BookmarksSubscription/bookmarksSubscriptionPromo.imageset/ FAB _ 48px - Blue.pdf new file mode 100644 index 0000000000..780947cdca Binary files /dev/null and b/iphone/Maps/Images.xcassets/BookmarksSubscription/bookmarksSubscriptionPromo.imageset/ FAB _ 48px - Blue.pdf differ diff --git a/iphone/Maps/Images.xcassets/BookmarksSubscription/bookmarksSubscriptionPromo.imageset/Contents.json b/iphone/Maps/Images.xcassets/BookmarksSubscription/bookmarksSubscriptionPromo.imageset/Contents.json new file mode 100644 index 0000000000..ef65d32571 --- /dev/null +++ b/iphone/Maps/Images.xcassets/BookmarksSubscription/bookmarksSubscriptionPromo.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : " FAB _ 48px - Blue.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 2d8e9684e5..037e29da7d 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -375,6 +375,8 @@ 4719A647219CBD7F009F9AA7 /* IBillingPendingTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4719A646219CBD7F009F9AA7 /* IBillingPendingTransaction.swift */; }; 4719A64E21A30C3B009F9AA7 /* PaidRouteStatistics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4719A64D21A30C3B009F9AA7 /* PaidRouteStatistics.swift */; }; 471BBD942130390F00EB17C9 /* TutorialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 471BBD932130390F00EB17C9 /* TutorialViewController.swift */; }; + 471C448C2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 471C448A2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.swift */; }; + 471C448D2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 471C448B2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.xib */; }; 4726254921C27D4B00C7BAAD /* PlacePageDescriptionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4726254821C27D4B00C7BAAD /* PlacePageDescriptionViewController.swift */; }; 47289E5A2212DFFF002ABFC0 /* EditOnWebAlertViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47289E582212DFFF002ABFC0 /* EditOnWebAlertViewController.swift */; }; 47289E5B2212DFFF002ABFC0 /* EditOnWebAlertViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 47289E592212DFFF002ABFC0 /* EditOnWebAlertViewController.xib */; }; @@ -1465,6 +1467,8 @@ 4719A646219CBD7F009F9AA7 /* IBillingPendingTransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBillingPendingTransaction.swift; sourceTree = ""; }; 4719A64D21A30C3B009F9AA7 /* PaidRouteStatistics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaidRouteStatistics.swift; sourceTree = ""; }; 471BBD932130390F00EB17C9 /* TutorialViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TutorialViewController.swift; sourceTree = ""; }; + 471C448A2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksSubscriptionGoToCatalogViewController.swift; sourceTree = ""; }; + 471C448B2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BookmarksSubscriptionGoToCatalogViewController.xib; sourceTree = ""; }; 4726254821C27D4B00C7BAAD /* PlacePageDescriptionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlacePageDescriptionViewController.swift; sourceTree = ""; }; 47289E582212DFFF002ABFC0 /* EditOnWebAlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditOnWebAlertViewController.swift; sourceTree = ""; }; 47289E592212DFFF002ABFC0 /* EditOnWebAlertViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EditOnWebAlertViewController.xib; sourceTree = ""; }; @@ -3616,6 +3620,8 @@ 47C8789822DF622400A772DA /* BookmarksSubscriptionFailViewController.xib */, 47C8789B22DF662700A772DA /* BookmarksSubscriptionExpiredViewController.swift */, 47C8789C22DF662700A772DA /* BookmarksSubscriptionExpiredViewController.xib */, + 471C448A2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.swift */, + 471C448B2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.xib */, ); path = Dialogs; sourceTree = ""; @@ -4992,6 +4998,7 @@ F6E2FD6E1E097BA00083EBEC /* MWMMapDownloaderSubplaceTableViewCell.xib in Resources */, 345E8F551F839E6C00A826CC /* GoogleService-Info.plist in Resources */, 3477528B1F725002000D46A3 /* UGCAddReviewRatingCell.xib in Resources */, + 471C448D2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.xib in Resources */, F6E2FD741E097BA00083EBEC /* MWMMapDownloaderTableViewCell.xib in Resources */, 349A13851DEC138C00C7DB60 /* MWMMobileInternetAlert.xib in Resources */, 34D3B04B1E389D05004100F9 /* MWMNoteCell.xib in Resources */, @@ -5674,6 +5681,7 @@ 34B924431DC8A29C0008D971 /* MWMMailViewController.mm in Sources */, 340475651E081A4600C92850 /* MWMRouter.mm in Sources */, 47E3C72F2111F472008B3B27 /* CoverVerticalModalTransitioning.swift in Sources */, + 471C448C2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.swift in Sources */, 346DB83D1E5C4F6700E3123E /* GalleryModel.swift in Sources */, 4710366522D3764600585272 /* BookmarksSubscriptionCellViewController.swift in Sources */, 34E776101F14B165003040B3 /* VisibleArea.swift in Sources */,