Manos Chorianopoulos

redesign WalletViewController part1

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -9,9 +9,75 @@ import UIKit
@objc public class WalletBannersTableViewCell: UITableViewCell {
@IBOutlet weak var sumBannerArrowImage: UIImageView!
@IBOutlet weak var sumBannerInnerView: UIView!
@IBOutlet weak var sumBadgeImage: UIImageView!
@IBOutlet weak var sumBadgeLabel: UILabel!
@IBOutlet weak var sumBannerLabel: UILabel!
@IBOutlet weak var dfyBannerView: UIView!
@IBOutlet weak var dfyBannerHeight: NSLayoutConstraint!
@IBOutlet weak var dfyBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var dfyBannerInnerView: UIView!
@IBOutlet weak var dfyBadgeImage: UIImageView!
@IBOutlet weak var dfyBadgeLabel: UILabel!
@IBOutlet weak var dfyBannerLabel: UILabel!
@IBOutlet weak var gfyBannerView: UIView!
@IBOutlet weak var gfyBannerHeight: NSLayoutConstraint!
@IBOutlet weak var gfyBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var gfyBannerInnerView: UIView!
@IBOutlet weak var couponBadgeImage: UIImageView!
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var gfyBannerLabel: UILabel!
@IBOutlet weak var marketBannerView: UIView!
@IBOutlet weak var marketBannerHeight: NSLayoutConstraint!
@IBOutlet weak var marketBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var marketBannerInnerView: UIView!
@IBOutlet weak var marketBadgeImage: UIImageView!
@IBOutlet weak var marketBadgeLabel: UILabel!
@IBOutlet weak var marketBannerLabel: UILabel!
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
sumBadgeImage.image = UIImage(named: "wallet_summary_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeImage.image = UIImage(named: "wallet_dfy_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeImage.image = UIImage(named: "wallet_coupons_4", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeImage.image = UIImage(named: "wallet_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
sumBannerInnerView.layer.cornerRadius = 16.5
sumBannerInnerView.layer.borderWidth = 1
sumBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
dfyBannerInnerView.layer.cornerRadius = 16.5
dfyBannerInnerView.layer.borderWidth = 1
dfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
gfyBannerInnerView.layer.cornerRadius = 16.5
gfyBannerInnerView.layer.borderWidth = 1
gfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
marketBannerInnerView.layer.cornerRadius = 16.5
marketBannerInnerView.layer.borderWidth = 1
marketBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
dfyBannerView.isHidden = true
dfyBannerHeight.constant = 0.0
dfyBannerTopSpace.constant = 0.0
gfyBannerView.isHidden = true
gfyBannerHeight.constant = 0.0
gfyBannerTopSpace.constant = 0.0
marketBannerView.isHidden = true
marketBannerHeight.constant = 0.0
marketBannerTopSpace.constant = 0.0
}
public override func setSelected(_ selected: Bool, animated: Bool) {
......@@ -20,4 +86,132 @@ import UIKit
// Configure the view for the selected state
}
func configureCell(totalCouponValue: Float, totalCouponDiscount: Float, unifiedCouponsDiscount: Float, forYouExpanded: Bool) {
if (forYouExpanded == false) {
sumBannerArrowImage.image = UIImage(named: "ic_down_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBannerView.isHidden = true
dfyBannerHeight.constant = 0.0
dfyBannerTopSpace.constant = 0.0
gfyBannerView.isHidden = true
gfyBannerHeight.constant = 0.0
gfyBannerTopSpace.constant = 0.0
marketBannerView.isHidden = true
marketBannerHeight.constant = 0.0
marketBannerTopSpace.constant = 0.0
} else {
sumBannerArrowImage.image = UIImage(named: "ic_up_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBannerView.isHidden = false
dfyBannerHeight.constant = 80.0
dfyBannerTopSpace.constant = 8.0
gfyBannerView.isHidden = false
gfyBannerHeight.constant = 80.0
gfyBannerTopSpace.constant = 8.0
marketBannerView.isHidden = false
marketBannerHeight.constant = 80.0
marketBannerTopSpace.constant = 8.0
}
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && unifiedCouponsDiscount == 0.0) {
sumBannerArrowImage.isHidden = true
} else {
sumBannerArrowImage.isHidden = false
}
// ===
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// if (sumRewards == 0.0) {
// sumBannerArrowImage.isHidden = true
// } else {
// sumBannerArrowImage.isHidden = false
// }
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
let sumNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let sumBoldText = sumRewardsString + "€"
let sumNormalText2 = " στο For You!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 14) ?? UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 14) ?? UIFont.boldSystemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let sumAttributedString = NSMutableAttributedString(string:sumNormalText1, attributes:attrRegular)
let sumBoldString = NSMutableAttributedString(string: sumBoldText, attributes:attrBold)
let sumNormalString = NSMutableAttributedString(string:sumNormalText2, attributes:attrRegular)
sumAttributedString.append(sumBoldString)
sumAttributedString.append(sumNormalString)
sumBannerLabel.attributedText = sumAttributedString
// ===
let totalCouponValueFixed = Float(round(100 * totalCouponValue) / 100)
var totalCouponValueString = "0"
totalCouponValueString = String(format: "%.2f", totalCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
dfyBadgeLabel.text = totalCouponValueString + "€"
let dfyNormalText1 = "Έχεις κερδίσει "
let dfyBoldText = totalCouponValueString + "€"
let dfyNormalText2 = " με το DEALS for YOU!"
let dfyAttributedString = NSMutableAttributedString(string:dfyNormalText1, attributes:attrRegular)
let dfyBoldString = NSMutableAttributedString(string: dfyBoldText, attributes:attrBold)
let dfyNormalString = NSMutableAttributedString(string:dfyNormalText2, attributes:attrRegular)
dfyAttributedString.append(dfyBoldString)
dfyAttributedString.append(dfyNormalString)
dfyBannerLabel.attributedText = dfyAttributedString
// ===
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
couponBadgeLabel.text = totalCouponDiscountString + "€"
let gfyNormalText1 = "Έχεις κερδίσει "
let gfyBoldText = totalCouponDiscountString + "€"
let gfyNormalText2 = " με το GIFTS for YOU!"
let gfyAttributedString = NSMutableAttributedString(string:gfyNormalText1, attributes:attrRegular)
let gfyBoldString = NSMutableAttributedString(string: gfyBoldText, attributes:attrBold)
let gfyNormalString = NSMutableAttributedString(string:gfyNormalText2, attributes:attrRegular)
gfyAttributedString.append(gfyBoldString)
gfyAttributedString.append(gfyNormalString)
gfyBannerLabel.attributedText = gfyAttributedString
// ===
let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
var marketDiscountString = "0"
marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
self.marketBadgeLabel.text = marketDiscountString + "€"
let marketNormalText1 = "Έχεις κερδίσει "
let marketBoldText = marketDiscountString + "€"
let marketNormalText2 = " με τα SuperMarket Deals!"
let marketAttributedString = NSMutableAttributedString(string:marketNormalText1, attributes:attrRegular)
let marketBoldString = NSMutableAttributedString(string: marketBoldText, attributes:attrBold)
let marketNormalString = NSMutableAttributedString(string:marketNormalText2, attributes:attrRegular)
marketAttributedString.append(marketBoldString)
marketAttributedString.append(marketNormalString)
marketBannerLabel.attributedText = marketAttributedString
}
}
......
......@@ -75,6 +75,8 @@ import SwiftEventBus
let totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
var unifiedCouponsDiscount:Float = 0.0
var forYouExpanded: Bool = false;
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -191,12 +193,12 @@ import SwiftEventBus
if (totalCouponValue == 0.0) {
dfyEarnBannerView.isHidden = true
dfyEarnBannerHeight.constant = 0
dfyEarnBannerTopSpace.constant = 0
// dfyEarnBannerTopSpace.constant = 0
} else {
dfyEarnBannerView.isHidden = false
dfyEarnBannerHeight.constant = 75
dfyEarnBannerTopSpace.constant = 30
// dfyEarnBannerTopSpace.constant = 30
}
......@@ -418,6 +420,10 @@ import SwiftEventBus
emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!"
updateMarketBadge()
// TODO: DELETE if emptyView is needed again
emptyView.isHidden = true
emptyViewHeight.constant = 0
}
public override func viewWillAppear(_ animated: Bool) {
......@@ -563,13 +569,14 @@ import SwiftEventBus
}
}
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
emptyView.isHidden = false
emptyViewHeight.constant = emptyView.intrinsicContentSize.height
} else {
emptyView.isHidden = true
emptyViewHeight.constant = 0
}
// TODO: UNCOMMENT if emptyView is needed again
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
// emptyView.isHidden = false
// emptyViewHeight.constant = emptyView.intrinsicContentSize.height
// } else {
// emptyView.isHidden = true
// emptyViewHeight.constant = 0
// }
}
// MARK: - API Functions
......@@ -686,6 +693,63 @@ import SwiftEventBus
}
}
@IBAction func sumBannerButtonAction(_ sender: Any) {
if (!(self.totalCouponValue == 0.0 && self.loyaltyBadge._couponCount == 0 && self.unifiedCouponsDiscount == 0.0)) {
self.forYouExpanded = !self.forYouExpanded
self.tableView.reloadData()
}
}
@IBAction func dfyBannerButtonAction(_ sender: Any) {
var totalCouponValue = swiftApi().getDealsCouponsSum()
if (totalCouponValue > 0.0) {
print("DFY coupon banner pressed!")
// analysis_pressed event
let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
dealsAnalysis._isPressed = true
SwiftEventBus.post("analysis_pressed", sender: dealsAnalysis)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_gifts_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "DealsBanner"))
}
}
@IBAction func gfyBannerButtonAction(_ sender: Any) {
if (loyaltyBadge._couponCount > 0) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_deals_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyAnalysisViewController") as! SwiftWarplyFramework.LoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func marketBannerButtonAction(_ sender: Any) {
// TODO: add action - open marketHistory after check
if (self.unifiedCouponsDiscount > 0.0) {
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "did_tap_deals_for_you_badge"
// firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
// SwiftEventBus.post("firebase", sender: firebaseEvent)
// swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "MarketLoyaltyAnalysisViewController") as! SwiftWarplyFramework.MarketLoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
}
// MARK: - TableView
......@@ -699,9 +763,9 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
if (section == 0) {
// TODO: Uncomment when UnifiedCoupons will be shown again
// if (self.totalCouponValue == 0.0 && self.loyaltyBadge._couponCount == 0 && self.unifiedCouponsDiscount == 0.0) {
return 0
// return 0
// } else {
// return 1
return 1
// }
} else if (section == 1) {
return self.unifiedCoupons.count
......@@ -722,9 +786,9 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
if (indexPath.section == 0) {
// TODO: Uncomment when UnifiedCoupons will be shown again
// if (self.totalCouponValue == 0.0 && self.loyaltyBadge._couponCount == 0 && self.unifiedCouponsDiscount == 0.0) {
return 0.0
// return 0.0
// } else {
// return UITableView.automaticDimension
return UITableView.automaticDimension
// }
} else if (indexPath.section == 1) {
if (self.unifiedCoupons.count > 0) {
......@@ -856,9 +920,12 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletBadgesTableViewCellId", for: indexPath) as! WalletBadgesTableViewCell
cell.configureCell(totalCouponValue: self.totalCouponValue, totalCouponDiscount: self.totalCouponDiscount, unifiedCouponsDiscount: self.unifiedCouponsDiscount)
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletBannersTableViewCellId", for: indexPath) as! WalletBannersTableViewCell
cell.configureCell(totalCouponValue: self.totalCouponValue, totalCouponDiscount: self.totalCouponDiscount, unifiedCouponsDiscount: self.unifiedCouponsDiscount, forYouExpanded: self.forYouExpanded)
return cell
// let cell = tableView.dequeueReusableCell(withIdentifier: "WalletBadgesTableViewCellId", for: indexPath) as! WalletBadgesTableViewCell
// cell.configureCell(totalCouponValue: self.totalCouponValue, totalCouponDiscount: self.totalCouponDiscount, unifiedCouponsDiscount: self.unifiedCouponsDiscount)
// return cell
} else if (indexPath.section == 1) {
let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponsTableViewCellId", for: indexPath) as! UnifiedCouponsTableViewCell
cell.configureCell(coupon: unifiedCoupons[indexPath.row])
......