Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

[IP-418] Update prices for promotional offers on payment screen

  • Loading branch information
mahmoud-adam85 authored and naira-cliqz committed Apr 5, 2019
1 parent 409a62b commit 0fa0bd94826eb52c88ed2d08924950063029b583
@@ -226,8 +226,11 @@ extension PaidControlCenterViewController : UpgradeLumenDelegate {
case .limited:
self.addUpgradeView()
self.disableView()
default:
print("Premium User")
case .premium(let premiumType, _):
if !premiumType.hasDashboard() {
self.addUpgradeView()
self.disableView()
}
}
}

@@ -65,6 +65,8 @@ public class SubscriptionController {
switch getCurrentSubscription() {
case .limited:
UserPreferences.instance.isProtectionOn = false
case .premium(let premiumType, _):
UserPreferences.instance.isProtectionOn = premiumType.hasDashboard()
default:
return
}
@@ -102,18 +104,6 @@ public class SubscriptionController {
return storeService.getSubscriptionUserId()
}

public func isVPNEnabled() -> Bool {
let currentSubscription = getCurrentSubscription()
switch currentSubscription {
case .trial(_):
return true
case .premium(let premiumType, _):
return premiumType.hasVPN()
default:
return false
}
}

public func getCurrentSubscription() -> LumenSubscriptionType {

if let purchasedProductIdentifier = UserDefaults.standard.string(forKey: purchasedProductIdentifierKey),
@@ -130,11 +120,48 @@ public class SubscriptionController {
return .limited
}

public func hasBasicSubscription() -> Bool {
public func getAvailableUpgradeOptions() -> [PremiumType] {
let currentSubscription = getCurrentSubscription()
switch currentSubscription {
case .premium(let premiumType, _):
if premiumType.hasDashboard() {
return [.Basic, .BasicAndVpn]
}
return [.Vpn, .BasicAndVpn]
default:
return [.Basic, .BasicAndVpn, .Vpn]
}
}

public func isVPNEnabled() -> Bool {
let currentSubscription = getCurrentSubscription()
switch currentSubscription {
case .trial(_):
return true
case .premium(let premiumType, _):
return premiumType.hasVPN()
default:
return false
}
}

public func isDashboardEnabled() -> Bool {
let currentSubscription = getCurrentSubscription()
switch currentSubscription {
case .trial(_):
return true
case .premium(let premiumType, _):
return premiumType.hasDashboard()
default:
return false
}
}

public func hasSubscription(_ premiumType: PremiumType) -> Bool {
let currentSubscription = getCurrentSubscription()
switch currentSubscription {
case .premium(let premiumType, _):
return premiumType == .Basic
return premiumType == premiumType
default:
return false
}
@@ -9,91 +9,69 @@
import UIKit

public enum PremiumType: String {
case Basic = "com.cliqz.ios.lumen.basic"
case Plus = "com.cliqz.ios.lumen.plus"
case Pro = "com.cliqz.ios.lumen.pro"
case Basic = "com.cliqz.ios.lumen.sale.basic"
case Vpn = "com.cliqz.ios.lumen.sale.vpn"
case BasicAndVpn = "com.cliqz.ios.lumen.sale.basic_vpn"

func hasVPN() -> Bool {
switch self {
case .Plus, .Pro:
case .Vpn, .BasicAndVpn:
return true
default:
return false
}
}

func getName() -> String {
func hasDashboard() -> Bool {
switch self {
case .Basic:
return NSLocalizedString("BASIC", tableName: "Lumen", comment: "BASIC Subscription name")
case .Pro:
return NSLocalizedString("PRO", tableName: "Lumen", comment: "PRO Subscription name")
case .Plus:
return NSLocalizedString("PLUS", tableName: "Lumen", comment: "PLUS Subscription name")
case .Basic, .BasicAndVpn:
return true
default:
return false
}
}

func getDescription() -> String {
func getName() -> String {
switch self {
case .Basic:
return NSLocalizedString("ULTIMATE PROTECTION: AD-BLOCKER_ANTI-TRACKING_ANTI-PHISHING", tableName: "Lumen", comment: "BASIC Subscription Description")
case .Pro:
return NSLocalizedString("VPN_ULTIMATE PROTECTION: DASHBOARD_AD-BLOCKER_ANTI-TRACKING_ANTI-PHISHING", tableName: "Lumen", comment: "PRO Subscription Description")
case .Plus:
return NSLocalizedString("VPN_ULTIMATE PROTECTION: DASHBOARD_AD-BLOCKER_ANTI-TRACKING_ANTI-PHISHING", tableName: "Lumen", comment: "PLUS Subscription Description")
return NSLocalizedString("BASIC", tableName: "Lumen", comment: "BASIC Subscription name")
case .Vpn:
return NSLocalizedString("VPN", tableName: "Lumen", comment: "VPN Subscription name")
case .BasicAndVpn:
return NSLocalizedString("Basic + VPN", tableName: "Lumen", comment: "Basic + VPN Subscription name")
}
}

func getDuration() -> String {
func getDescription() -> String {
switch self {
case .Basic:
return NSLocalizedString("12 MONTHS", tableName: "Lumen", comment: "BASIC Subscription duration")
case .Pro:
return NSLocalizedString("12 MONTHS", tableName: "Lumen", comment: "PRO Subscription duration")
case .Plus:
return NSLocalizedString("1 MONTH", tableName: "Lumen", comment: "PLUS Subscription duration")
return NSLocalizedString("ULTIMATE PROTECTION ONLINE", tableName: "Lumen", comment: "BASIC Subscription Description")
case .Vpn:
return NSLocalizedString("PROTECTION FROM HACKERS WITH VPN", tableName: "Lumen", comment: "VPN Subscription Description")
case .BasicAndVpn:
return NSLocalizedString("ULTIMATE PROTECTION ONLINE +\nPROTECTION FROM HACKERS WITH VPN", tableName: "Lumen", comment: "Basic + VPN Subscription Description")
}
}

func getPrice() -> String {
// TODO: Commented strings might be needed in future, when we put back payment flow. Prices are removed for BETA testing
switch self {
case .Basic:
// return NSLocalizedString("47.99€/year", tableName: "Lumen", comment: "BASIC Subscription price")
return NSLocalizedString("Yearly", tableName: "Lumen", comment: "BASIC Subscription price")
case .Pro:
// return NSLocalizedString("95.99€/year", tableName: "Lumen", comment: "PRO Subscription price")
return NSLocalizedString("Yearly", tableName: "Lumen", comment: "PRO Subscription price")
case .Plus:
// return NSLocalizedString("9.99€/month", tableName: "Lumen", comment: "PLUS Subscription price")
return NSLocalizedString("Monthly", tableName: "Lumen", comment: "PLUS Subscription price")
}
}


func getBilling() -> String {
// TODO: Commented strings might be needed in future, when we put back payment flow. Prices are removed for BETA testing
return ""
/*
switch self {
case .Basic:
return NSLocalizedString("Corresponds to 4€/month", tableName: "Lumen", comment: "BASIC Subscription billing")
case .Pro:
return NSLocalizedString("Corresponds to 8€/month", tableName: "Lumen", comment: "PRO Subscription billing")
case .Plus:
return NSLocalizedString("Corresponds to 119.88€/year", tableName: "Lumen", comment: "PLUS Subscription billing")
return NSLocalizedString("1,99 €/MONTH", tableName: "Lumen", comment: "BASIC Subscription price")
case .Vpn:
return NSLocalizedString("4,99 €/MONAT", tableName: "Lumen", comment: "VPN Subscription price")
case .BasicAndVpn:
return NSLocalizedString("4,99 €/MONTH", tableName: "Lumen", comment: "Basic + VPN Subscription price")
}
*/
}

func getTelemeteryTarget() -> String {
switch self {
case .Basic:
return "subscribe_basic"
case .Pro:
return "subscribe_plus_monthly"
case .Plus:
return "subscribe_plus_annually"
case .Vpn:
return "subscribe_vpn"
case .BasicAndVpn:
return "subscribe_basic_vpn"
}
}
}
@@ -17,17 +17,12 @@ class SubscribeButton: UIButton {

class SubscriptionTableViewCell: UITableViewCell {
let nameLabel = UILabel()
let includeLabel = UILabel()
let vpnIcon = UIImageView()
let durationLabel = UILabel()
let priceLabel = UILabel()
let billingLabel = UILabel()
let descriptionLabel = UILabel()
let bestOfferLabel = UILabel()
let subscribeButton = SubscribeButton()
let frameView = UIImageView()
var isProCell: Bool = false
var isBasicCell: Bool = false

var buyButtonHandler: ((_ premiumType: PremiumType) -> Void)?
var premiumType: PremiumType? {
@@ -45,15 +40,11 @@ class SubscriptionTableViewCell: UITableViewCell {

private func setupComponents() {
self.addSubview(nameLabel)
includeLabel.text = NSLocalizedString("INCL.", tableName: "Lumen", comment: "Include vpn label")
self.addSubview(includeLabel)
self.addSubview(vpnIcon)
self.addSubview(durationLabel)
self.addSubview(priceLabel)
self.addSubview(billingLabel)
descriptionLabel.numberOfLines = 0
self.addSubview(descriptionLabel)

bestOfferLabel.numberOfLines = 0
bestOfferLabel.textAlignment = .right
self.addSubview(bestOfferLabel)

self.addSubview(frameView)
@@ -69,85 +60,49 @@ class SubscriptionTableViewCell: UITableViewCell {
self.backgroundColor = UIColor.clear
nameLabel.font = UIFont.systemFont(ofSize: 18.0, weight: .semibold)
nameLabel.textColor = isProCell ? UIColor.black : UIColor.white
includeLabel.font = UIFont.systemFont(ofSize: 10.0, weight: .regular)
includeLabel.textColor = isProCell ? UIColor.black : UIColor.white

durationLabel.font = UIFont.systemFont(ofSize: 16.0, weight: .semibold)
durationLabel.textColor = isProCell ? UIColor.black : UIColor.white

priceLabel.font = UIFont.systemFont(ofSize: 18.0, weight: .medium)
priceLabel.textColor = UIColor.white

billingLabel.font = UIFont.systemFont(ofSize: 10.0, weight: .regular)
billingLabel.textColor = UIColor(colorString: "BDC0CE")

descriptionLabel.font = UIFont.systemFont(ofSize: 12.0, weight: .medium)
descriptionLabel.textColor = UIColor(colorString: "BDC0CE")

subscribeButton.titleLabel?.font = UIFont.systemFont(ofSize: 16.0, weight: .medium)
subscribeButton.backgroundColor = UIColor.lumenBrightBlue
subscribeButton.setTitleColor(UIColor.white, for: .normal)
subscribeButton.layer.cornerRadius = 15

frameView.image = isProCell ? UIImage(named: "Frame_Solid") : UIImage(named: "Frame")
vpnIcon.image = isProCell ? UIImage(named: "VPN_Dark") : UIImage(named: "VPN_White")

bestOfferLabel.font = UIFont.systemFont(ofSize: 9.0, weight: .medium)
bestOfferLabel.font = UIFont.systemFont(ofSize: 12.0, weight: .medium)
bestOfferLabel.textColor = UIColor.black
bestOfferLabel.isHidden = !isProCell
includeLabel.isHidden = isBasicCell
vpnIcon.isHidden = isBasicCell
}

private func setConstraints() {

nameLabel.snp.remakeConstraints { (make) in
if isProCell {
make.leading.equalToSuperview().inset(20.0)
make.top.equalToSuperview().inset(20.0)
make.top.equalToSuperview().inset(15.0)
} else {
make.leading.equalToSuperview().inset(30.0)
make.top.equalToSuperview().inset(13.0)
}
}

includeLabel.snp.remakeConstraints { (make) in
make.bottom.equalTo(nameLabel.snp.bottom)
make.leading.equalTo(nameLabel.snp.trailing).offset(5)
}

vpnIcon.snp.remakeConstraints { (make) in
make.centerY.equalTo(nameLabel.snp.centerY)
make.leading.equalTo(includeLabel.snp.trailing).offset(5)
}

durationLabel.snp.remakeConstraints { (make) in
make.centerY.equalTo(nameLabel.snp.centerY)
if isProCell {
make.trailing.equalToSuperview().inset(20.0)
} else {
make.trailing.equalToSuperview().inset(30.0)
}
}
bestOfferLabel.snp.remakeConstraints { (make) in
make.trailing.equalTo(durationLabel.snp.trailing)
make.top.equalToSuperview().inset(8)
make.trailing.equalToSuperview().inset(20)
make.centerY.equalTo(nameLabel)
}

priceLabel.snp.remakeConstraints { (make) in
make.leading.equalTo(nameLabel.snp.leading)
make.top.equalTo(nameLabel.snp.bottom).offset(10.0)
}

billingLabel.snp.remakeConstraints { (make) in
make.leading.equalTo(nameLabel.snp.leading)
make.top.equalTo(priceLabel.snp.bottom)
make.top.equalTo(nameLabel.snp.bottom).offset(23.0)
}

descriptionLabel.snp.remakeConstraints { (make) in
make.leading.equalTo(nameLabel.snp.leading)
make.trailing.equalToSuperview().inset(25.0)
make.bottom.equalToSuperview().inset(10.0)
make.bottom.equalToSuperview().inset(20.0)
}

subscribeButton.snp.remakeConstraints { (make) in
@@ -156,7 +111,7 @@ class SubscriptionTableViewCell: UITableViewCell {
} else {
make.trailing.equalToSuperview().inset(30.0)
}
make.top.equalTo(durationLabel.snp.bottom).offset(15.0)
make.centerY.equalTo(priceLabel)
make.width.equalTo(110.0)
make.height.equalTo(30.0)
}
@@ -181,22 +136,21 @@ class SubscriptionTableViewCell: UITableViewCell {

private func configureCell(_ premiumType: PremiumType) {
nameLabel.text = premiumType.getName()
durationLabel.text = premiumType.getDuration()
priceLabel.text = premiumType.getPrice()
billingLabel.text = premiumType.getBilling()
descriptionLabel.text = premiumType.getDescription()
bestOfferLabel.text = ""//NSLocalizedString("BEST VALUE: SAVE 20%", tableName: "Lumen", comment: "BEST VALUE: SAVE 20%")
bestOfferLabel.text = NSLocalizedString("BEST OFFER\nLIMITED TIME ONLY", tableName: "Lumen", comment: "BEST OFFER\nLIMITED TIME ONLY")

isProCell = premiumType == .Pro
isBasicCell = premiumType == .Basic
if SubscriptionController.shared.hasBasicSubscription() {
if isBasicCell {
subscribeButton.setTitle(NSLocalizedString("SUBSCRIBED", tableName: "Lumen", comment: "Subscribe Button"), for: .normal)
subscribeButton.isUserInteractionEnabled = false
} else if isProCell {
subscribeButton.setTitle(NSLocalizedString("UPGRADE", tableName: "Lumen", comment: "Subscribe Button"), for: .normal)
subscribeButton.isUserInteractionEnabled = true
}
isProCell = premiumType == .BasicAndVpn
if SubscriptionController.shared.hasSubscription(premiumType) {
subscribeButton.setTitle(NSLocalizedString("SUBSCRIBED", tableName: "Lumen", comment: "Subscribe Button"), for: .normal)
subscribeButton.isUserInteractionEnabled = false
subscribeButton.backgroundColor = UIColor.clear
subscribeButton.setTitleColor(UIColor.lumenBrightBlue, for: .normal)
} else {
subscribeButton.setTitle(NSLocalizedString("UPGRADE", tableName: "Lumen", comment: "Subscribe Button"), for: .normal)
subscribeButton.isUserInteractionEnabled = true
subscribeButton.backgroundColor = UIColor.lumenBrightBlue
subscribeButton.setTitleColor(UIColor.white, for: .normal)
}
self.setStyles()
self.setConstraints()

0 comments on commit 0fa0bd9

Please sign in to comment.