diff options
author | Aleksey Belouosv <aleksey@maps.me> | 2019-08-16 17:52:49 +0300 |
---|---|---|
committer | Zoia <niakris90@gmail.com> | 2019-08-16 19:23:59 +0300 |
commit | 8e51f7c2cfb656e0ec6825ac92c84b7f996a8ace (patch) | |
tree | 335c7222bc1e494b7dc4ae38b9d79b4171320541 | |
parent | e075985c6e2756bc6c4f9c0b1fcb4e6ca215fa7f (diff) |
[iOS] fix bookmarks subscription screen layoutandroid-gr-922
https://jira.mail.ru/browse/MAPSME-11499
https://jira.mail.ru/browse/MAPSME-11508
https://jira.mail.ru/browse/MAPSME-11503
https://jira.mail.ru/browse/MAPSME-11505
5 files changed, 68 insertions, 16 deletions
diff --git a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionCellViewController.swift b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionCellViewController.swift index c7c6bd6b06..7e3a91f8b1 100644 --- a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionCellViewController.swift +++ b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionCellViewController.swift @@ -23,10 +23,10 @@ class BookmarksSubscriptionCellViewController: UIViewController { func setSelected(_ selected: Bool, animated: Bool = false) { isSelected = selected let setSelectedClosure = { [unowned self] in - self.titleLabel.textColor = selected ? .linkBlue() : .blackPrimaryText() + self.titleLabel.textColor = selected ? .subscriptionCellTitle() : .blackSecondaryText() self.subtitleLabel.textColor = selected ? .linkBlue() : .blackSecondaryText() - self.priceLabel.textColor = selected ? .linkBlue() : .blackPrimaryText() - self.contentView.backgroundColor = selected ? .linkBlueHighlighted() : .clear + self.priceLabel.textColor = selected ? .subscriptionCellTitle() : .blackSecondaryText() + self.contentView.backgroundColor = selected ? .subscriptionCellBackground() : .clear self.containerView.backgroundColor = selected ? .white() : .clear } diff --git a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift index 71fe1582ee..596f61e58f 100644 --- a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift +++ b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.swift @@ -1,3 +1,5 @@ +import SafariServices + class BookmarksSubscriptionViewController: MWMViewController { @IBOutlet private var annualView: UIView! @IBOutlet private var monthlyView: UIView! @@ -82,8 +84,9 @@ class BookmarksSubscriptionViewController: MWMViewController { let monthlyPrice = subscriptions[0].price let annualPrice = subscriptions[1].price - let discount = monthlyPrice.multiplying(by: 12).subtracting(annualPrice) - let discountString = formatter.string(from: discount) + + let twelveMonthPrice = monthlyPrice.multiplying(by: 12) + let discount = twelveMonthPrice.subtracting(annualPrice).dividing(by: twelveMonthPrice).multiplying(by: 100) self?.monthlyViewController.config(title: L("montly_subscription_title"), subtitle: L("montly_subscription_message"), @@ -93,7 +96,7 @@ class BookmarksSubscriptionViewController: MWMViewController { subtitle: L("annual_subscription_message"), price: formatter.string(from: annualPrice) ?? "", image: UIImage(named: "bookmarksSubscriptionYear")!, - discount: (discountString != nil) ? "- \(discountString!)" : nil) + discount: "- \(discount.rounding(accordingToBehavior: nil).intValue) %") } } @@ -142,10 +145,39 @@ class BookmarksSubscriptionViewController: MWMViewController { Statistics.logEvent(kStatInappPay, withParameters: [kStatPurchase: MWMPurchaseManager.bookmarksSubscriptionServerId()]) } + @IBAction func onRestore(_ sender: UIButton) { + loadingView.isHidden = false + InAppPurchase.bookmarksSubscriptionManager.restore { [weak self] result in + self?.loadingView.isHidden = true + let alertText: String + switch result { + case .valid: + alertText = L("restore_success_alert") + case .notValid: + alertText = L("restore_no_subscription_alert") + case .serverError, .authError: + alertText = L("restore_error_alert") + } + MWMAlertViewController.activeAlert().presentInfoAlert(L("restore_subscription"), text: alertText) + } + } + @IBAction func onClose(_ sender: UIButton) { onCancel?() Statistics.logEvent(kStatInappCancel, withParameters: [kStatPurchase: MWMPurchaseManager.bookmarksSubscriptionServerId()]) } + + @IBAction func onTerms(_ sender: UIButton) { + guard let url = URL(string: MWMAuthorizationViewModel.termsOfUseLink()) else { return } + let safari = SFSafariViewController(url: url) + self.present(safari, animated: true, completion: nil) + } + + @IBAction func onPrivacy(_ sender: UIButton) { + guard let url = URL(string: MWMAuthorizationViewModel.privacyPolicyLink()) else { return } + let safari = SFSafariViewController(url: url) + self.present(safari, animated: true, completion: nil) + } } extension BookmarksSubscriptionViewController: SubscriptionManagerListener { diff --git a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.xib b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.xib index 1a28c78a54..cbb02898f5 100644 --- a/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.xib +++ b/iphone/Maps/Bookmarks/Catalog/BookmarksSubscriptionViewController.xib @@ -41,10 +41,10 @@ <rect key="frame" x="0.0" y="20" width="414" height="716"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Eiz-QQ-h0b"> - <rect key="frame" x="0.0" y="0.0" width="414" height="669.66666666666663"/> + <rect key="frame" x="0.0" y="0.0" width="414" height="675.66666666666663"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Unlimited access to 5000+ guides!" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bOS-sQ-rkD"> - <rect key="frame" x="16" y="16.000000000000004" width="382" height="57.333333333333343"/> + <rect key="frame" x="16" y="22.000000000000004" width="382" height="57.333333333333343"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="24"/> <nil key="textColor"/> <nil key="highlightedColor"/> @@ -55,7 +55,7 @@ </userDefinedRuntimeAttributes> </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Every kind of journey. Whether alone or with friends, hiking or sunbathing" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vzD-qz-Fwt"> - <rect key="frame" x="16" y="89.333333333333329" width="382" height="33.666666666666671"/> + <rect key="frame" x="16" y="95.333333333333329" width="382" height="33.666666666666671"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> <nil key="textColor"/> <nil key="highlightedColor"/> @@ -66,7 +66,7 @@ </userDefinedRuntimeAttributes> </label> <scrollView multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" bouncesZoom="NO" translatesAutoresizingMaskIntoConstraints="NO" id="q5w-jW-Chn"> - <rect key="frame" x="33" y="157" width="348" height="254"/> + <rect key="frame" x="33" y="163" width="348" height="254"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GGO-lU-mzy"> <rect key="frame" x="0.0" y="0.0" width="348" height="254"/> @@ -115,7 +115,7 @@ </constraints> </scrollView> <button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="neX-0h-hs4" userLabel="Continue"> - <rect key="frame" x="50" y="445" width="314" height="50"/> + <rect key="frame" x="50" y="451" width="314" 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> @@ -141,7 +141,7 @@ </connections> </button> <button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a64-qc-DrZ" userLabel="Restore"> - <rect key="frame" x="50" y="503" width="314" height="50"/> + <rect key="frame" x="50" y="509" width="314" height="50"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <accessibility key="accessibilityConfiguration" identifier="welcome_storyboard.button_next2"/> <constraints> @@ -157,9 +157,12 @@ <userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/> <userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="restore_subscription"/> </userDefinedRuntimeAttributes> + <connections> + <action selector="onRestore:" destination="-1" eventType="touchUpInside" id="3br-rR-hqk"/> + </connections> </button> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="justified" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tWZ-GP-RxW"> - <rect key="frame" x="20" y="561" width="374" height="64.666666666666629"/> + <rect key="frame" x="20" y="567" width="374" height="64.666666666666629"/> <string key="text">Payment will be charged to your iTunes account at confirmation of purchase. The subscription will automatically renew unless auto-renew is turned off at least 24 hours before the end of the current period. Your account will be charged according to your plan for renewal within 24 hours prior to the end of the current period. You can manage or turn off auto-renew in your Apple ID account settings at any time of your purchase.</string> <fontDescription key="fontDescription" type="system" pointSize="9"/> <color key="textColor" white="0.0" alpha="0.31555008561643838" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -171,7 +174,7 @@ </userDefinedRuntimeAttributes> </label> <button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="awa-we-Pjk" userLabel="TermsOfUse"> - <rect key="frame" x="20" y="625.66666666666663" width="66" height="44"/> + <rect key="frame" x="20" y="631.66666666666663" width="66" height="44"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <accessibility key="accessibilityConfiguration" identifier="welcome_storyboard.button_next2"/> <constraints> @@ -187,9 +190,12 @@ <userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="blackSecondaryText"/> <userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="terms_of_use"/> </userDefinedRuntimeAttributes> + <connections> + <action selector="onTerms:" destination="-1" eventType="touchUpInside" id="Khm-jH-zzz"/> + </connections> </button> <button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalCompressionResistancePriority="749" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="60B-kT-Eev" userLabel="PrivacyPolicy"> - <rect key="frame" x="325" y="625.66666666666663" width="69" height="44"/> + <rect key="frame" x="325" y="631.66666666666663" width="69" height="44"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <accessibility key="accessibilityConfiguration" identifier="welcome_storyboard.button_next2"/> <constraints> @@ -205,6 +211,9 @@ <userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="blackSecondaryText"/> <userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="privacy_policy"/> </userDefinedRuntimeAttributes> + <connections> + <action selector="onPrivacy:" destination="-1" eventType="touchUpInside" id="ySf-IG-mMz"/> + </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="v0Z-5m-unD"> <rect key="frame" x="362" y="0.0" width="44" height="44"/> @@ -232,7 +241,7 @@ <constraint firstItem="q5w-jW-Chn" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="Eiz-QQ-h0b" secondAttribute="leading" constant="13" id="9kc-0C-7dp"/> <constraint firstItem="60B-kT-Eev" firstAttribute="top" secondItem="tWZ-GP-RxW" secondAttribute="bottom" id="HNk-gd-Qc6"/> <constraint firstAttribute="trailing" secondItem="a64-qc-DrZ" secondAttribute="trailing" constant="50" id="INc-Pv-5M3"/> - <constraint firstItem="bOS-sQ-rkD" firstAttribute="top" secondItem="Eiz-QQ-h0b" secondAttribute="top" constant="16" id="JTG-8l-iqj"/> + <constraint firstItem="bOS-sQ-rkD" firstAttribute="top" secondItem="Eiz-QQ-h0b" secondAttribute="top" constant="22" id="JTG-8l-iqj"/> <constraint firstItem="awa-we-Pjk" firstAttribute="leading" secondItem="Eiz-QQ-h0b" secondAttribute="leading" constant="20" id="Loh-WS-cJr"/> <constraint firstAttribute="trailing" secondItem="tWZ-GP-RxW" secondAttribute="trailing" constant="20" id="OFb-vM-2cl"/> <constraint firstItem="a64-qc-DrZ" firstAttribute="leading" secondItem="Eiz-QQ-h0b" secondAttribute="leading" constant="50" id="R8g-2f-TIi"/> diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.h b/iphone/Maps/Categories/UIColor+MapsMeColor.h index d53ed3629c..53cb2ca237 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.h +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.h @@ -56,6 +56,8 @@ + (UIColor *)shadowColorBlue; + (UIColor *)shadowColorPurple; + (UIColor *)subscriptionCellBorder; ++ (UIColor *)subscriptionCellBackground; ++ (UIColor *)subscriptionCellTitle; + (UIColor *)colorWithName:(NSString *)colorName; + (UIColor *)colorFromHexString:(NSString *)hexString; diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.mm b/iphone/Maps/Categories/UIColor+MapsMeColor.mm index 7f0d8d4f1b..7fbe525515 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.mm +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.mm @@ -407,4 +407,13 @@ UIColor * color(SEL cmd) return [UIColor colorWithRed:scaled(174) green:scaled(184) blue:scaled(190) alpha:alpha100]; } ++ (UIColor *)subscriptionCellBackground { + return [UIColor colorWithRed:scaled(208) green:scaled(246) blue:scaled(255) alpha:alpha100]; +} + ++ (UIColor *)subscriptionCellTitle { + return [UIColor colorWithRed:scaled(14) green:scaled(101) blue:scaled(188) alpha:alpha100]; +} + + @end |