[iOS] crown button

https://jira.mail.ru/browse/MAPSME-11763
This commit is contained in:
Aleksey Belouosv 2019-09-06 18:32:55 +03:00 committed by Arsentiy Milchakov
parent 18298b93fb
commit 3ef36d63d2
13 changed files with 237 additions and 3 deletions

View file

@ -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] }

View file

@ -0,0 +1,25 @@
@objc class BookmarksSubscriptionGoToCatalogViewController: UIViewController {
private let transitioning = FadeTransitioning<AlertPresentationController>()
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()
}
}

View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BookmarksSubscriptionGoToCatalogViewController" customModule="maps_me" customModuleProvider="target">
<connections>
<outlet property="view" destination="SOP-ru-g5D" id="1nu-A8-eNS"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="SOP-ru-g5D">
<rect key="frame" x="0.0" y="0.0" width="284" height="433"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bookmarksSubscriptionSuccess" translatesAutoresizingMaskIntoConstraints="NO" id="23B-dz-OpC">
<rect key="frame" x="61" y="16" width="162" height="117"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="YOU HAVE UNLIMITED ACCESS" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vQn-4C-oYe">
<rect key="frame" x="16" y="149" width="252" height="50.5"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="21"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="popup_subscription_success_map_title"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="bold22"/>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Now, yout can add to your map detailed description of the best places" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OsJ-Ey-N4m">
<rect key="frame" x="16" y="215.5" width="252" height="57.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.0" alpha="0.39696596750000002" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="popup_subscription_success_map_message"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular16"/>
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackSecondaryText"/>
</userDefinedRuntimeAttributes>
</label>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xa4-LJ-vic" userLabel="Continue">
<rect key="frame" x="16" y="301" width="252" height="50"/>
<color key="backgroundColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" identifier="welcome_storyboard.button_next2"/>
<constraints>
<constraint firstAttribute="width" constant="252" id="0uH-cr-IVd"/>
<constraint firstAttribute="height" constant="50" id="x62-GF-sVh"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/>
<state key="normal" title="OPEN CATALOG">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="textColorHighlightedName" value="white"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="medium14"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="6"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="white"/>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundHighlightedColorName" value="linkBlueHighlighted"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="popup_subscription_success_map_start_button"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onOk:" destination="-1" eventType="touchUpInside" id="vvi-ED-wvI"/>
</connections>
</button>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3aS-Ex-OZk" userLabel="NotNow">
<rect key="frame" x="16" y="359" width="252" height="50"/>
<accessibility key="accessibilityConfiguration" identifier="welcome_storyboard.button_next2"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="NYL-Ec-J0Q"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/>
<state key="normal" title="Not now">
<color key="titleColor" red="0.11764705882352941" green="0.58823529411764708" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="textColorHighlightedName" value="linkBlueHighlighted"/>
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="medium14"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="6"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundHighlightedColorName" value="white"/>
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="popup_subscription_success_map_not_now_button"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="onCancel:" destination="-1" eventType="touchUpInside" id="zvK-iK-S11"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="OsJ-Ey-N4m" firstAttribute="leading" secondItem="SOP-ru-g5D" secondAttribute="leading" constant="16" id="FBM-0v-ZgS"/>
<constraint firstAttribute="trailing" secondItem="vQn-4C-oYe" secondAttribute="trailing" constant="16" id="G42-7C-n8e"/>
<constraint firstItem="23B-dz-OpC" firstAttribute="top" secondItem="SOP-ru-g5D" secondAttribute="top" constant="16" id="Jdp-rF-k82"/>
<constraint firstAttribute="trailing" secondItem="OsJ-Ey-N4m" secondAttribute="trailing" constant="16" id="LHa-jk-1nd"/>
<constraint firstItem="Xa4-LJ-vic" firstAttribute="top" secondItem="OsJ-Ey-N4m" secondAttribute="bottom" constant="28" id="UeK-gA-1V9"/>
<constraint firstItem="3aS-Ex-OZk" firstAttribute="leading" secondItem="Xa4-LJ-vic" secondAttribute="leading" id="V6F-aI-3Rk"/>
<constraint firstItem="23B-dz-OpC" firstAttribute="centerX" secondItem="SOP-ru-g5D" secondAttribute="centerX" id="fZ0-bw-7mL"/>
<constraint firstItem="Xa4-LJ-vic" firstAttribute="leading" secondItem="SOP-ru-g5D" secondAttribute="leading" constant="16" id="hnZ-D9-LId"/>
<constraint firstItem="3aS-Ex-OZk" firstAttribute="top" secondItem="Xa4-LJ-vic" secondAttribute="bottom" constant="8" id="ien-94-sMH"/>
<constraint firstAttribute="bottom" secondItem="3aS-Ex-OZk" secondAttribute="bottom" constant="24" id="k3Q-84-aBg"/>
<constraint firstAttribute="trailing" secondItem="Xa4-LJ-vic" secondAttribute="trailing" constant="16" id="kqN-p0-ByB"/>
<constraint firstItem="3aS-Ex-OZk" firstAttribute="trailing" secondItem="Xa4-LJ-vic" secondAttribute="trailing" id="krQ-6x-s93"/>
<constraint firstItem="vQn-4C-oYe" firstAttribute="leading" secondItem="SOP-ru-g5D" secondAttribute="leading" constant="16" id="lT7-ry-J73"/>
<constraint firstItem="OsJ-Ey-N4m" firstAttribute="top" secondItem="vQn-4C-oYe" secondAttribute="bottom" constant="16" id="mrN-f1-ASC"/>
<constraint firstItem="vQn-4C-oYe" firstAttribute="top" secondItem="23B-dz-OpC" secondAttribute="bottom" constant="16" id="yRa-7a-dl0"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="KiP-gT-tgg"/>
<point key="canvasLocation" x="46.376811594202906" y="203.90625"/>
</view>
</objects>
<resources>
<image name="bookmarksSubscriptionSuccess" width="162" height="117"/>
</resources>
</document>

View file

@ -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<MWMPlacePageProtocol> 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)

View file

@ -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;

View file

@ -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
{

View file

@ -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

View file

@ -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

View file

@ -35,5 +35,6 @@ typedef NS_ENUM(NSUInteger, MWMEyeDiscoveryEvent)
+ (void)discoveryItemClickedWithEvent:(MWMEyeDiscoveryEvent)event;
+ (void)transitionToBookingWithPos:(CGPoint)pos;
+ (void)promoAfterBookingShownWithCityId:(NSString *)cityId;
+ (void)crownClicked;
@end

View file

@ -45,4 +45,9 @@
{
eye::Eye::Event::PromoAfterBookingShown(cityId.UTF8String);
}
+ (void)crownClicked {
eye::Eye::Event::CrownClicked();
}
@end

View file

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : " FAB _ 48px - Blue.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View file

@ -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 = "<group>"; };
4719A64D21A30C3B009F9AA7 /* PaidRouteStatistics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaidRouteStatistics.swift; sourceTree = "<group>"; };
471BBD932130390F00EB17C9 /* TutorialViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TutorialViewController.swift; sourceTree = "<group>"; };
471C448A2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksSubscriptionGoToCatalogViewController.swift; sourceTree = "<group>"; };
471C448B2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BookmarksSubscriptionGoToCatalogViewController.xib; sourceTree = "<group>"; };
4726254821C27D4B00C7BAAD /* PlacePageDescriptionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlacePageDescriptionViewController.swift; sourceTree = "<group>"; };
47289E582212DFFF002ABFC0 /* EditOnWebAlertViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditOnWebAlertViewController.swift; sourceTree = "<group>"; };
47289E592212DFFF002ABFC0 /* EditOnWebAlertViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EditOnWebAlertViewController.xib; sourceTree = "<group>"; };
@ -3616,6 +3620,8 @@
47C8789822DF622400A772DA /* BookmarksSubscriptionFailViewController.xib */,
47C8789B22DF662700A772DA /* BookmarksSubscriptionExpiredViewController.swift */,
47C8789C22DF662700A772DA /* BookmarksSubscriptionExpiredViewController.xib */,
471C448A2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.swift */,
471C448B2322A7C800C307EC /* BookmarksSubscriptionGoToCatalogViewController.xib */,
);
path = Dialogs;
sourceTree = "<group>";
@ -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 */,