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