Manos Chorianopoulos

refactor WalletVC v2

This diff could not be displayed because it is too large.
......@@ -41,6 +41,8 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
// Initialization code
couponBgImage.image = UIImage(named: "coupon_bg", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponImage.image = UIImage(named: "coupon_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
borderView.addDashedBorderVertical(color: UIColor(red: 0.44, green: 0.44, blue: 0.44, alpha: 1.00), width: 1.0, height: 110.0)
}
......@@ -73,7 +75,7 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
for merchant in merchantList {
if (merchant._uuid == couponSetData?.merchant_uuid) {
// couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
// self.postImageURL = merchant._img_preview
nameLabel.text = merchant._admin_name
break;
}
......
......@@ -54,6 +54,7 @@ import SwiftEventBus
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var marketBadgeImage: UIImageView!
@IBOutlet weak var marketBadgeLabel: UILabel!
@IBOutlet weak var badgeLinesImage: UIImageView!
public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
......@@ -71,27 +72,27 @@ import SwiftEventBus
self.hidesBottomBarWhenPushed = true
// TODO: DELETE ===>
// let coupon = swiftApi.ActiveDFYCouponModel()
// coupon._value = "12"
// // coupon._date = "2022-12-05 01:55:01"
// coupon._date = "2022-10-26 23:59:01"
// coupon._code = "123456789"
// let coupon2 = swiftApi.ActiveDFYCouponModel()
// coupon2._value = "23"
// coupon2._date = "2022-11-05 01:55"
// coupon2._code = "234567891"
// let coupon3 = swiftApi.ActiveDFYCouponModel()
// coupon3._value = "34"
// coupon3._date = "2022-07-01 01:55"
// coupon3._code = "345678912"
// let couponsArray: Array<swiftApi.ActiveDFYCouponModel> = [coupon, coupon2, coupon3, coupon3, coupon3]
// swiftApi().setActiveDFYCoupons(dfyCoupons: couponsArray)
// dfyCoupons = swiftApi().getActiveDFYCoupons()
// let coupon = swiftApi.ActiveDFYCouponModel()
// coupon._value = "12"
// // coupon._date = "2022-12-05 01:55:01"
// coupon._date = "2022-10-26 23:59:01"
// coupon._code = "123456789"
//
// let coupon2 = swiftApi.ActiveDFYCouponModel()
// coupon2._value = "23"
// coupon2._date = "2022-11-05 01:55"
// coupon2._code = "234567891"
//
// let coupon3 = swiftApi.ActiveDFYCouponModel()
// coupon3._value = "34"
// coupon3._date = "2022-07-01 01:55"
// coupon3._code = "345678912"
//
// let couponsArray: Array<swiftApi.ActiveDFYCouponModel> = [coupon, coupon2, coupon3, coupon3, coupon3]
//
// swiftApi().setActiveDFYCoupons(dfyCoupons: couponsArray)
//
// dfyCoupons = swiftApi().getActiveDFYCoupons()
// TODO: DELETE <===
setBackButton()
......@@ -112,6 +113,9 @@ import SwiftEventBus
couponEarnImage.image = UIImage(named: "wallet_coupons_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyLogoImage.image = UIImage(named: "dfy_logo_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
activeCodeImage.image = UIImage(named: "active_code_logo", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
sumBadgeImage.image = UIImage(named: "wallet_summary", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
badgeLinesImage.image = UIImage(named: "wallet_badge_lines", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
profileImage.layer.cornerRadius = 32.5
profileImage.layer.borderWidth = 1
......@@ -154,6 +158,9 @@ import SwiftEventBus
questionnaireButton.layer.cornerRadius = 7.0
// Rewards View
rewardsLabel.text = "COSMOTE Επιβράβευση"
dfyEarnBannerView.layer.cornerRadius = 5.0
dfyEarnBannerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
dfyEarnBannerView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
......@@ -166,10 +173,19 @@ import SwiftEventBus
dfyEarnBannerView.isHidden = true
dfyEarnBannerHeight.constant = 0
dfyEarnBannerTopSpace.constant = 0
// Rewards View
dfyBadgeImage.image = UIImage(named: "wallet_dfy_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeLabel.isHidden = true
} else {
dfyEarnBannerView.isHidden = false
dfyEarnBannerHeight.constant = 75
dfyEarnBannerTopSpace.constant = 30
// Rewards View
dfyBadgeImage.image = UIImage(named: "wallet_dfy_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeLabel.isHidden = false
}
totalCouponValue = Float(round(100 * totalCouponValue) / 100)
......@@ -194,15 +210,26 @@ import SwiftEventBus
dfyEarnLabel.attributedText = attributedString
dfyEarnAmountLabel.text = totalCouponValueString + "€"
// Rewards View
dfyBadgeLabel.text = totalCouponValueString + "€"
if (loyaltyBadge._couponCount == 0) {
couponEarnView.isHidden = true
couponEarnViewHeight.constant = 0
couponEarnViewTopSpace.constant = 0
// Rewards View
couponBadgeImage.image = UIImage(named: "wallet_coupons_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeLabel.isHidden = true
} else {
couponEarnView.isHidden = false
couponEarnViewHeight.constant = 75
couponEarnViewTopSpace.constant = 30
// Rewards View
couponBadgeImage.image = UIImage(named: "wallet_coupons_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeLabel.isHidden = false
}
couponEarnView.layer.cornerRadius = 5.0
......@@ -236,10 +263,35 @@ import SwiftEventBus
couponEarnLabel.attributedText = coupAttributedString
couponEarnAmountLabel.text = totalCouponDiscountString + "€"
// Rewards View
couponBadgeLabel.text = totalCouponDiscountString + "€"
print("Loyalty Badge Value: " + totalCouponDiscountString)
print("Loyalty Badge Count: " + String(loyaltyBadge._couponCount))
// Rewards View - Market Badge
// TODO: Fix empty check
if (false) {
marketBadgeImage.image = UIImage(named: "wallet_market_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = true
} else {
marketBadgeImage.image = UIImage(named: "wallet_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = false
}
// TODO: Fix dynamic value
marketBadgeLabel.text = "10,00" + "€"
// Rewards View
// TODO: Add market value
let sumRewards = totalCouponValue + totalCouponDiscount
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
// activeCodeView
activeCodeView.layer.cornerRadius = 5.0
activeCodeView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
activeCodeView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
......@@ -377,7 +429,15 @@ import SwiftEventBus
emptyImage.image = UIImage(named: "ic_empty_wallet", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!"
// TODO: FIX emptyView check
// TODO: FIX emptyView check - add market badge check
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0) {
rewardsView.isHidden = true
} else {
rewardsView.isHidden = false
}
// TODO: FIX emptyView check - add market badge check
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0) {
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0) {
emptyView.isHidden = false
......@@ -555,6 +615,44 @@ import SwiftEventBus
SwiftEventBus.post("dfy_coupon_details", sender: couponDetails)
}
@IBAction func dfyBadgeButtonAction(_ 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 couponBadgeButtonAction(_ 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 marketBadgeButtonAction(_ sender: Any) {
print("Market Badge pressed!")
// TODO: add action - open marketHistory after check
}
}
// MARK: - TableView
......@@ -570,7 +668,11 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
return 3
// return self.unifiedCoupons.count
} else if (section == 1) {
return 1
if (self.dfyCoupons.count > 0) {
return 1
} else {
return 0
}
}
return self.coupons.count
}
......@@ -613,18 +715,24 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
return view
} else if (section == 1) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 68))
view.backgroundColor = .clear
if (self.dfyCoupons.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 68))
view.backgroundColor = .clear
let imageView = UIImageView(frame: CGRect(x: 20, y: 20, width: view.frame.width / 3.5, height: 38))
imageView.contentMode = .scaleAspectFit
let imageView = UIImageView(frame: CGRect(x: 20, y: 20, width: view.frame.width / 3.5, height: 38))
imageView.contentMode = .scaleAspectFit
if let dfyHeaderImage = UIImage(named: "dfy_logo_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
imageView.image = dfyHeaderImage
if let dfyHeaderImage = UIImage(named: "dfy_logo_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
imageView.image = dfyHeaderImage
}
view.addSubview(imageView)
return view
} else {
return nil
}
view.addSubview(imageView)
return view
} else {
// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 71))
......