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 @@
-
+
-
+
@@ -115,7 +115,7 @@