Manos Chorianopoulos

box redesign LoyaltyHistoryViewController

......@@ -36,14 +36,23 @@ import SwiftEventBus
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var gfyBannerLabel: UILabel!
@IBOutlet weak var boxBannerParentView: UIView!
@IBOutlet weak var boxBannerInnerParentView: UIView!
@IBOutlet weak var boxBannerInnerView: UIView!
@IBOutlet weak var boxBadgeImage: UIImageView!
@IBOutlet weak var boxBadgeLabel: UILabel!
@IBOutlet weak var boxBannerLabel: UILabel!
public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public var boxCoupons:Array<swiftApi.ActiveBoxCouponModel> = swiftApi().getActiveBoxCoupons()
var totalCouponValue = swiftApi().getDealsCouponsSum()
var totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
var unifiedCouponsDiscount:Float = 0.0
var boxCouponValue = swiftApi().getBoxCouponsSum()
public override func viewDidLoad() {
......@@ -91,6 +100,7 @@ import SwiftEventBus
dfyBadgeImage.image = UIImage(named: "history_banner_dfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeImage.image = UIImage(named: "history_banner_sm", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeImage.image = UIImage(named: "history_banner_gfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
boxBadgeImage.image = UIImage(named: "history_banner_box", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
sectionTitleLabel.text = "Εξαργυρωμένα κουπόνια"
......@@ -118,6 +128,7 @@ import SwiftEventBus
self.coupons = swiftApi().getCouponList()
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.dfyCoupons = swiftApi().getActiveDFYCoupons()
self.boxCoupons = swiftApi().getActiveBoxCoupons()
self.matchOldSMCoupons()
self.updateMarketBadge()
......@@ -205,7 +216,7 @@ import SwiftEventBus
// === SUM banner === //
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount + boxCouponValue
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
......@@ -309,6 +320,40 @@ import SwiftEventBus
gfyAttributedString.append(gfyBoldString)
gfyAttributedString.append(gfyNormalString)
gfyBannerLabel.attributedText = gfyAttributedString
// === BOX banner === //
boxBannerParentView.backgroundColor = .clear
boxBannerInnerParentView.backgroundColor = .white
// boxBannerInnerView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05)
boxBannerInnerView.backgroundColor = .white
boxBannerInnerParentView.layer.cornerRadius = 16.0
boxBannerInnerView.layer.cornerRadius = 16.0
// boxBannerInnerView.layer.borderWidth = 1
// boxBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
boxBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
boxBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
boxBannerParentView.layer.shadowOpacity = 1.0
boxBannerParentView.layer.shadowRadius = 2.0
let boxCouponValueFixed = Float(round(100 * boxCouponValue) / 100)
var boxCouponValueString = "0"
boxCouponValueString = String(format: "%.2f", boxCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
boxBadgeLabel.text = boxCouponValueString + "€"
let boxNormalText1 = "Μέχρι τώρα έχεις όφελος "
let boxBoldText = boxCouponValueString + "€"
let boxNormalText2 = " από το BOX"
let boxAttributedString = NSMutableAttributedString(string:boxNormalText1, attributes:attrRegular)
let boxBoldString = NSMutableAttributedString(string: boxBoldText, attributes:attrBold)
let boxNormalString = NSMutableAttributedString(string:boxNormalText2, attributes:attrRegular)
boxAttributedString.append(boxBoldString)
boxAttributedString.append(boxNormalString)
boxBannerLabel.attributedText = boxAttributedString
}
// MARK: - Actions
......@@ -369,4 +414,24 @@ import SwiftEventBus
self.navigationController?.pushViewController(vc, animated: true)
// }
}
@IBAction func boxBannerButtonAction(_ sender: Any) {
print("BOX coupon banner pressed!")
// // box_analysis_pressed event
// let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
// dealsAnalysis._isPressed = true
// SwiftEventBus.post("box_analysis_pressed", sender: dealsAnalysis)
// box_analysis_pressed event
let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
dealsAnalysis._isPressed = true
SwiftEventBus.post("box_analysis_pressed")
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_box_badge"
firebaseEvent.setParameter = ("screen", "Loyalty History")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "BoxBanner"))
}
}
......