Manos Chorianopoulos

box redesign MyRewards

...@@ -417,15 +417,12 @@ import SwiftEventBus ...@@ -417,15 +417,12 @@ import SwiftEventBus
417 417
418 @IBAction func boxBannerButtonAction(_ sender: Any) { 418 @IBAction func boxBannerButtonAction(_ sender: Any) {
419 print("BOX coupon banner pressed!") 419 print("BOX coupon banner pressed!")
420 -// // box_analysis_pressed event
421 -// let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
422 -// dealsAnalysis._isPressed = true
423 -// SwiftEventBus.post("box_analysis_pressed", sender: dealsAnalysis)
424 420
425 // box_analysis_pressed event 421 // box_analysis_pressed event
426 - let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel() 422 + let dealsAnalysis = swiftApi.WarplyBoxAnalysisEventModel()
427 dealsAnalysis._isPressed = true 423 dealsAnalysis._isPressed = true
428 - SwiftEventBus.post("box_analysis_pressed") 424 + SwiftEventBus.post("box_analysis_pressed", sender: dealsAnalysis)
425 + // SwiftEventBus.post("box_analysis_pressed")
429 426
430 let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() 427 let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
431 firebaseEvent._eventName = "did_tap_box_badge" 428 firebaseEvent._eventName = "did_tap_box_badge"
......
This diff could not be displayed because it is too large.
...@@ -8,13 +8,51 @@ ...@@ -8,13 +8,51 @@
8 import UIKit 8 import UIKit
9 9
10 @objc public class WalletActiveCouponCollectionViewCell: UICollectionViewCell { 10 @objc public class WalletActiveCouponCollectionViewCell: UICollectionViewCell {
11 + @IBOutlet weak var badgeViewParent: UIView!
12 + @IBOutlet weak var badgeView: UIView!
13 + @IBOutlet weak var badgeImage: UIImageView!
14 + @IBOutlet weak var badgeLabel: UILabel!
15 + @IBOutlet weak var badgeCountView: UIView!
16 + @IBOutlet weak var badgeCountLabel: UILabel!
11 17
12 public override func awakeFromNib() { 18 public override func awakeFromNib() {
13 super.awakeFromNib() 19 super.awakeFromNib()
14 20
21 + // Badge Banner
22 +// badgeViewParent.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
23 + badgeViewParent.backgroundColor = .white
24 + badgeViewParent.layer.cornerRadius = 16.0
25 + badgeViewParent.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
26 + badgeViewParent.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
27 + badgeViewParent.layer.shadowOpacity = 1.0
28 + badgeViewParent.layer.shadowRadius = 2.0
29 +
30 +// badgeView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05)
31 + badgeView.backgroundColor = .white
32 + badgeView.layer.cornerRadius = 16.0
33 +
34 + badgeCountView.layer.cornerRadius = 4.0
35 + badgeCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
15 } 36 }
16 37
17 - func configureCell() { 38 + func configureCell(badgeId: String, badgeCount: Int) {
39 + if (badgeId == "dfy") {
40 + badgeImage.image = UIImage(named: "wallet_banner_dfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
41 + badgeLabel.text = "DEALS FOR YOU"
42 +
43 + } else if (badgeId == "sm") {
44 + badgeImage.image = UIImage(named: "wallet_banner_sm", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
45 + badgeLabel.text = "SUPERMARKET DEALS"
46 +
47 + } else if (badgeId == "gfy") {
48 + badgeImage.image = UIImage(named: "wallet_banner_gfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
49 + badgeLabel.text = "FREE COUPONS"
50 +
51 + } else if (badgeId == "box") {
52 + badgeImage.image = UIImage(named: "wallet_banner_box", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
53 + badgeLabel.text = "BOX"
54 + }
18 55
56 + badgeCountLabel.text = String(badgeCount)
19 } 57 }
20 } 58 }
......
...@@ -6,30 +6,22 @@ ...@@ -6,30 +6,22 @@
6 // 6 //
7 7
8 import UIKit 8 import UIKit
9 +import SwiftEventBus
9 10
10 @objc public class WalletActiveCouponsScrollTableViewCell: UITableViewCell { 11 @objc public class WalletActiveCouponsScrollTableViewCell: UITableViewCell {
11 @IBOutlet weak var sectionTitleLabel: UILabel! 12 @IBOutlet weak var sectionTitleLabel: UILabel!
12 @IBOutlet weak var historyButtonImage: UIImageView! 13 @IBOutlet weak var historyButtonImage: UIImageView!
13 14
14 - @IBOutlet weak var dfyViewParent: UIView! 15 + @IBOutlet weak var collectionView: UICollectionView!
15 - @IBOutlet weak var dfyView: UIView! 16 + @IBOutlet weak var dotLeft: UIView!
16 - @IBOutlet weak var dfyImage: UIImageView! 17 + @IBOutlet weak var dotLeftWidth: NSLayoutConstraint!
17 - @IBOutlet weak var dfyLabel: UILabel! 18 + @IBOutlet weak var dotLeftHeight: NSLayoutConstraint!
18 - @IBOutlet weak var dfyCountView: UIView! 19 + @IBOutlet weak var dotRight: UIView!
19 - @IBOutlet weak var dfyCountLabel: UILabel! 20 + @IBOutlet weak var dotRightWidth: NSLayoutConstraint!
20 - 21 + @IBOutlet weak var dotRightHeight: NSLayoutConstraint!
21 - @IBOutlet weak var smView: UIView!
22 - @IBOutlet weak var smImage: UIImageView!
23 - @IBOutlet weak var smLabel: UILabel!
24 - @IBOutlet weak var smCountView: UIView!
25 - @IBOutlet weak var smCountLabel: UILabel!
26 -
27 - @IBOutlet weak var gfyView: UIView!
28 - @IBOutlet weak var gfyImage: UIImageView!
29 - @IBOutlet weak var gfyLabel: UILabel!
30 - @IBOutlet weak var gfyCountView: UIView!
31 - @IBOutlet weak var gfyCountLabel: UILabel!
32 22
23 + var parent: UIViewController?
24 + public var activeCouponBadges:Array<swiftApi.WalletActiveCouponBadgeModel> = []
33 25
34 public override func awakeFromNib() { 26 public override func awakeFromNib() {
35 super.awakeFromNib() 27 super.awakeFromNib()
...@@ -41,71 +33,186 @@ import UIKit ...@@ -41,71 +33,186 @@ import UIKit
41 historyButtonImage.image = historyButtonImage.image?.withRenderingMode(.alwaysTemplate) 33 historyButtonImage.image = historyButtonImage.image?.withRenderingMode(.alwaysTemplate)
42 historyButtonImage.tintColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00) 34 historyButtonImage.tintColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
43 35
44 - // DFY Banner 36 + collectionView.contentInset.left = 17
45 -// dfyViewParent.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00) 37 + collectionView.contentInset.right = 17
46 - dfyViewParent.backgroundColor = .white 38 +
47 - dfyViewParent.layer.cornerRadius = 16.0 39 + dotLeftWidth.constant = 12
48 - dfyViewParent.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor 40 + dotLeftHeight.constant = 12
49 - dfyViewParent.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) 41 + dotLeft.layer.cornerRadius = 6
50 - dfyViewParent.layer.shadowOpacity = 1.0 42 +
51 - dfyViewParent.layer.shadowRadius = 2.0 43 + dotRightWidth.constant = 8
44 + dotRightHeight.constant = 8
45 + dotRight.layer.cornerRadius = 4
46 +
47 + }
48 +
49 + public override func setSelected(_ selected: Bool, animated: Bool) {
50 + super.setSelected(selected, animated: animated)
51 +
52 + // Configure the view for the selected state
53 + }
54 +
55 + func configureCell(dfyCount: Int, smCount: Int, gfyCount: Int, boxCount: Int) {
56 + sortBadges(dfyCount, smCount, gfyCount, boxCount)
57 + }
52 58
53 -// dfyView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05) 59 + func sortBadges(_ dfyCount: Int, _ smCount: Int, _ gfyCount: Int, _ boxCount: Int) {
54 - dfyView.backgroundColor = .white 60 +// deals weight 3
55 - dfyView.layer.cornerRadius = 16.0 61 +// sm weight 2
62 +// free weight 1
63 +// box weight 0
64 +
65 + let DFYBadge = swiftApi.WalletActiveCouponBadgeModel()
66 + DFYBadge._id = "dfy"
67 + DFYBadge._count = dfyCount
68 + DFYBadge._weight = 3
69 +
70 + let SMBadge = swiftApi.WalletActiveCouponBadgeModel()
71 + SMBadge._id = "sm"
72 + SMBadge._count = smCount
73 + SMBadge._weight = 2
74 +
75 + let GFYBadge = swiftApi.WalletActiveCouponBadgeModel()
76 + GFYBadge._id = "gfy"
77 + GFYBadge._count = gfyCount
78 + GFYBadge._weight = 1
79 +
80 + let BOXBadge = swiftApi.WalletActiveCouponBadgeModel()
81 + BOXBadge._id = "box"
82 + BOXBadge._count = boxCount
83 + BOXBadge._weight = 0
84 +
85 + let tempActiveCouponBadges:Array<swiftApi.WalletActiveCouponBadgeModel> = [DFYBadge, SMBadge, GFYBadge, BOXBadge]
86 +// var tempActiveCouponBadges:Array<swiftApi.WalletActiveCouponBadgeModel> = []
87 +// tempActiveCouponBadges.append(DFYBadge)
88 +// tempActiveCouponBadges.append(SMBadge)
89 +// tempActiveCouponBadges.append(GFYBadge)
90 +// tempActiveCouponBadges.append(BOXBadge)
91 +
92 + let sortedActiveCouponBadges = tempActiveCouponBadges.sorted {
93 + ($0._weight) > ($1._weight)
94 + }
95 + .sorted {
96 + ($0._count) > ($1._count)
97 + }
56 98
57 - dfyImage.image = UIImage(named: "wallet_banner_dfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 99 + activeCouponBadges = sortedActiveCouponBadges
58 100
59 - dfyLabel.text = "DEALS FOR YOU" 101 + collectionView.reloadData();
60 102
61 - dfyCountView.layer.cornerRadius = 4.0 103 + }
62 - dfyCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
63 104
64 - // SM Banner 105 +}
65 -// smView.backgroundColor = UIColor(red: 1.00, green: 0.99, blue: 0.97, alpha: 1.00)
66 - smView.backgroundColor = .white
67 - smView.layer.cornerRadius = 16.0
68 - smView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
69 - smView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
70 - smView.layer.shadowOpacity = 1.0
71 - smView.layer.shadowRadius = 2.0
72 106
73 - smImage.image = UIImage(named: "wallet_banner_sm", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 107 +extension WalletActiveCouponsScrollTableViewCell: UIScrollViewDelegate {
74 108
75 - smLabel.text = "SUPERMARKET DEALS" 109 + public func scrollViewDidScroll(_ scrollView: UIScrollView) {
110 + let contentOffsetX = scrollView.contentOffset.x
111 + if contentOffsetX >= (scrollView.contentSize.width - scrollView.bounds.width) - 20 {
76 112
77 - smCountView.layer.cornerRadius = 4.0 113 + dotLeftWidth.constant = 8
78 - smCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00) 114 + dotLeftHeight.constant = 8
115 + dotLeft.layer.cornerRadius = 4
79 116
80 - // GFY Banner 117 + dotRightWidth.constant = 12
81 -// gfyView.backgroundColor = UIColor(red: 0.96, green: 0.97, blue: 0.98, alpha: 1.00) 118 + dotRightHeight.constant = 12
82 - gfyView.backgroundColor = .white 119 + dotRight.layer.cornerRadius = 6
83 - gfyView.layer.cornerRadius = 16.0
84 - gfyView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
85 - gfyView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
86 - gfyView.layer.shadowOpacity = 1.0
87 - gfyView.layer.shadowRadius = 2.0
88 120
89 - gfyImage.image = UIImage(named: "wallet_banner_gfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 121 + } else {
122 + dotLeftWidth.constant = 12
123 + dotLeftHeight.constant = 12
124 + dotLeft.layer.cornerRadius = 6
90 125
91 -// gfyLabel.text = "GIFTS FOR YOU" 126 + dotRightWidth.constant = 8
92 -// gfyLabel.text = "Free coupons" 127 + dotRightHeight.constant = 8
93 - gfyLabel.text = "FREE COUPONS" 128 + dotRight.layer.cornerRadius = 4
129 + }
94 130
95 - gfyCountView.layer.cornerRadius = 4.0
96 - gfyCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
97 } 131 }
132 +}
98 133
99 - public override func setSelected(_ selected: Bool, animated: Bool) { 134 +extension WalletActiveCouponsScrollTableViewCell: UICollectionViewDataSource,UICollectionViewDelegate {
100 - super.setSelected(selected, animated: animated) 135 + public func numberOfSections(in collectionView: UICollectionView) -> Int {
136 + return 1
137 + }
101 138
102 - // Configure the view for the selected state 139 + public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
140 + return activeCouponBadges.count
141 + }
142 +
143 + public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
144 + let badgeId = activeCouponBadges[indexPath.row]._id;
145 + let badgeCount = activeCouponBadges[indexPath.row]._count;
146 + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "WalletActiveCouponCollectionViewCellId", for: indexPath) as! WalletActiveCouponCollectionViewCell
147 + cell.configureCell(badgeId: badgeId, badgeCount: badgeCount)
148 + return cell;
149 + }
150 +
151 + public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
152 +
153 + let badgeId = activeCouponBadges[indexPath.row]._id
154 +
155 + if (badgeId == "dfy") {
156 + print("Active DFY coupon banner Tapped!")
157 +
158 + swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveDealsBanner"))
159 +
160 + let couponDetails = swiftApi.ActiveDFYCouponEventModel()
161 + couponDetails._isPressed = true
162 + SwiftEventBus.post("dfy_coupon_details", sender: couponDetails)
163 +
164 + } else if (badgeId == "sm") {
165 + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
166 + firebaseEvent._eventName = "did_tap_market_active_badge"
167 + firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
168 + SwiftEventBus.post("firebase", sender: firebaseEvent)
169 +
170 + swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveMarketBanner"))
171 +
172 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
173 + let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController
174 + parent?.navigationController?.pushViewController(vc, animated: true)
175 +
176 + } else if (badgeId == "gfy") {
177 + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
178 + firebaseEvent._eventName = "did_tap_gifts_for_you_active_badge"
179 + firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
180 + SwiftEventBus.post("firebase", sender: firebaseEvent)
181 +
182 + swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveLoyaltyBanner"))
183 +
184 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: SwiftWarplyFramework.CouponsViewController.self))
185 + if let vc = storyboard.instantiateViewController(withIdentifier: "CouponsViewController") as? SwiftWarplyFramework.CouponsViewController{
186 + parent?.navigationController?.pushViewController(vc,animated: true)
187 + }
188 +
189 + } else if (badgeId == "box") {
190 + print("Active BOX coupon banner Tapped!")
191 +
192 + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
193 + firebaseEvent._eventName = "did_tap_box_active_badge"
194 + firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
195 + SwiftEventBus.post("firebase", sender: firebaseEvent)
196 +
197 + swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveBoxBanner"))
198 +
199 +// SwiftEventBus.post("box_coupon_details")
200 +
201 + let couponDetails = swiftApi.ActiveBoxCouponEventModel()
202 + couponDetails._isPressed = true
203 + SwiftEventBus.post("box_coupon_details", sender: couponDetails)
204 +
205 + }
206 + }
207 +
208 + // Distance Between Item Cells
209 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
210 + return 5
103 } 211 }
104 212
105 - func configureCell(dfyCount: Int, smCount: Int, gfyCount: Int) { 213 + // Cell Margin
106 - dfyCountLabel.text = String(dfyCount) 214 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
107 - smCountLabel.text = String(smCount) 215 + return UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0)
108 - gfyCountLabel.text = String(gfyCount)
109 } 216 }
110 217
111 } 218 }
......
...@@ -69,6 +69,7 @@ import SwiftEventBus ...@@ -69,6 +69,7 @@ import SwiftEventBus
69 public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge() 69 public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
70 public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer() 70 public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
71 public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = [] 71 public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
72 + public var boxCoupons:Array<swiftApi.ActiveBoxCouponModel> = swiftApi().getActiveBoxCoupons()
72 73
73 var timerWallet: DispatchSourceTimer? 74 var timerWallet: DispatchSourceTimer?
74 var seconds: Int = 0 75 var seconds: Int = 0
...@@ -1386,8 +1387,9 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -1386,8 +1387,9 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
1386 1387
1387 1388
1388 if (indexPath.section == 0) { 1389 if (indexPath.section == 0) {
1389 - let cell = tableView.dequeueReusableCell(withIdentifier: "WalletActiveCouponsTableViewCellId", for: indexPath) as! WalletActiveCouponsTableViewCell 1390 + let cell = tableView.dequeueReusableCell(withIdentifier: "WalletActiveCouponsScrollTableViewCellId", for: indexPath) as! WalletActiveCouponsScrollTableViewCell
1390 - cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count) 1391 + cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count, boxCount: self.boxCoupons.count)
1392 + cell.parent = self
1391 return cell 1393 return cell
1392 1394
1393 } else if (indexPath.section == 1) { 1395 } else if (indexPath.section == 1) {
......
...@@ -4920,6 +4920,24 @@ public class swiftApi { ...@@ -4920,6 +4920,24 @@ public class swiftApi {
4920 } 4920 }
4921 4921
4922 4922
4923 + public class WarplyBoxAnalysisEventModel {
4924 + private var isPressed: Bool
4925 +
4926 + public init() {
4927 + self.isPressed = false
4928 + }
4929 +
4930 + public var _isPressed: Bool {
4931 + get { // getter
4932 + return self.isPressed
4933 + }
4934 + set(newValue) { //setter
4935 + self.isPressed = newValue
4936 + }
4937 + }
4938 + }
4939 +
4940 +
4923 public class ActiveDFYCouponEventModel { 4941 public class ActiveDFYCouponEventModel {
4924 private var isPressed: Bool 4942 private var isPressed: Bool
4925 4943
...@@ -4938,6 +4956,24 @@ public class swiftApi { ...@@ -4938,6 +4956,24 @@ public class swiftApi {
4938 } 4956 }
4939 4957
4940 4958
4959 + public class ActiveBoxCouponEventModel {
4960 + private var isPressed: Bool
4961 +
4962 + public init() {
4963 + self.isPressed = false
4964 + }
4965 +
4966 + public var _isPressed: Bool {
4967 + get { // getter
4968 + return self.isPressed
4969 + }
4970 + set(newValue) { //setter
4971 + self.isPressed = newValue
4972 + }
4973 + }
4974 + }
4975 +
4976 +
4941 public class WarplyCCMSEnabledModel { 4977 public class WarplyCCMSEnabledModel {
4942 private var isActivated: Bool 4978 private var isActivated: Bool
4943 4979
......