Manos Chorianopoulos

refactor WalletVC v1

...@@ -8,10 +8,172 @@ ...@@ -8,10 +8,172 @@
8 import UIKit 8 import UIKit
9 9
10 class ActiveCodeTableViewCell: UITableViewCell { 10 class ActiveCodeTableViewCell: UITableViewCell {
11 + @IBOutlet weak var activeCodeView: UIView!
12 + @IBOutlet weak var activeCodeViewHeight: NSLayoutConstraint!
13 + @IBOutlet weak var activeCodesCountLabel: UILabel!
14 + @IBOutlet weak var activeCodeLabel: UILabel!
15 + @IBOutlet weak var activeCodeExpirationLabel: UILabel!
16 + @IBOutlet weak var activeCodeImage: UIImageView!
17 + @IBOutlet weak var activeCodeScrollView: UIScrollView!
18 + @IBOutlet weak var activeCodeScrollViewHeight: NSLayoutConstraint!
19 + @IBOutlet weak var activeCodeContentView: UIView!
20 + @IBOutlet weak var activeCodeContentViewHeight: NSLayoutConstraint!
21 +
22 + public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
11 23
12 override func awakeFromNib() { 24 override func awakeFromNib() {
13 super.awakeFromNib() 25 super.awakeFromNib()
14 - // Initialization code 26 +
27 + // TODO: DELETE ===>
28 + // let coupon = swiftApi.ActiveDFYCouponModel()
29 + // coupon._value = "12"
30 + // // coupon._date = "2022-12-05 01:55:01"
31 + // coupon._date = "2022-10-26 23:59:01"
32 + // coupon._code = "123456789"
33 +
34 + // let coupon2 = swiftApi.ActiveDFYCouponModel()
35 + // coupon2._value = "23"
36 + // coupon2._date = "2022-11-05 01:55"
37 + // coupon2._code = "234567891"
38 +
39 + // let coupon3 = swiftApi.ActiveDFYCouponModel()
40 + // coupon3._value = "34"
41 + // coupon3._date = "2022-07-01 01:55"
42 + // coupon3._code = "345678912"
43 +
44 + // let couponsArray: Array<swiftApi.ActiveDFYCouponModel> = [coupon, coupon2, coupon3, coupon3, coupon3]
45 +
46 + // swiftApi().setActiveDFYCoupons(dfyCoupons: couponsArray)
47 +
48 + // dfyCoupons = swiftApi().getActiveDFYCoupons()
49 + // TODO: DELETE <===
50 +
51 + activeCodeView.layer.cornerRadius = 5.0
52 + activeCodeView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
53 + activeCodeView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
54 + activeCodeView.layer.shadowOpacity = 1.0
55 + activeCodeView.layer.shadowRadius = 6.0
56 +
57 + activeCodeImage.image = UIImage(named: "active_code_logo", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
58 +
59 + if (dfyCoupons.count > 0) {
60 + if (dfyCoupons.count == 1) {
61 + let dateFormatter = DateFormatter()
62 + dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
63 + // dateFormatter.dateFormat = "yyyy-MM-dd HH:mm"
64 +
65 + // sort dfyCoupons by date
66 + dfyCoupons.sort(by: {
67 + let date1 = dateFormatter.date(from: $0._date)
68 + let date2 = dateFormatter.date(from: $1._date)
69 +
70 + if ((date1 != nil) && (date2 != nil)) {
71 + return date1!.compare(date2!) == .orderedAscending
72 + } else {
73 + return false
74 + }
75 +
76 + })
77 +
78 + // Get days from now of the most recet coupon
79 + var daysFromNow = ""
80 + let calendar = Calendar.current
81 +
82 + // Replace the hour (time) of both dates with 00:00
83 + let date1 = calendar.startOfDay(for: Date())
84 + if let date2 = dateFormatter.date(from: dfyCoupons[0]._date) {
85 + let components = calendar.dateComponents([.day], from: date1, to: date2)
86 + daysFromNow = (components.day) != nil ? String((components.day ?? 0) + 1) : ""
87 + }
88 +
89 + activeCodesCountLabel.text = "Ενεργός κωδικός:"
90 + // activeCodeLabel.text = dfyCoupons[0]._code
91 + let newLabel = CopyableLabel()
92 + newLabel.text = String(dfyCoupons[0]._code)
93 + newLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 19)
94 + newLabel.textColor = UIColor(rgb: 0x3C5365)
95 + newLabel.frame.size.width = newLabel.intrinsicContentSize.width
96 + newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
97 + activeCodeContentView.addSubview(newLabel)
98 + // set the btn frame origin
99 + newLabel.frame.origin.x = 0
100 + newLabel.frame.origin.y = 0
101 + let scrollHeight = newLabel.intrinsicContentSize.height
102 + activeCodeContentViewHeight.constant = scrollHeight
103 + activeCodeScrollViewHeight.constant = scrollHeight
104 +
105 + activeCodeExpirationLabel.isHidden = false
106 + if (daysFromNow == "1") {
107 + activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρα"
108 + } else {
109 + activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρες"
110 + }
111 +
112 + } else {
113 + var tagHeight:CGFloat = 30
114 + let tagPadding: CGFloat = 0
115 + let tagSpacingX: CGFloat = 0
116 + let tagSpacingY: CGFloat = 2
117 +
118 + let containerWidth = activeCodeContentView.frame.size.width
119 +
120 + var currentOriginX: CGFloat = 0
121 + var currentOriginY: CGFloat = 0
122 +
123 + // var couponCodesString = ""
124 + for (index, item) in dfyCoupons.enumerated() {
125 + let newLabel = CopyableLabel()
126 + newLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 19)
127 + newLabel.textColor = UIColor(rgb: 0x3C5365)
128 +
129 + if (index == (dfyCoupons.endIndex - 1)) {
130 + // couponCodesString += String(item._code)
131 + newLabel.text = String(item._code)
132 + } else {
133 + // couponCodesString += String(item._code) + ", "
134 + newLabel.text = String(item._code) + ", "
135 + }
136 +
137 + newLabel.frame.size.width = newLabel.intrinsicContentSize.width + tagPadding
138 + newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
139 + tagHeight = newLabel.intrinsicContentSize.height
140 + activeCodeContentView.addSubview(newLabel)
141 +
142 + // if current X + label width will be greater than container view width
143 + // "move to next row"
144 + if currentOriginX + newLabel.frame.width > containerWidth {
145 + currentOriginX = 0
146 + currentOriginY += tagHeight + tagSpacingY
147 + }
148 +
149 + // set the btn frame origin
150 + newLabel.frame.origin.x = currentOriginX
151 + newLabel.frame.origin.y = currentOriginY
152 +
153 + // increment current X by btn width + spacing
154 + currentOriginX += newLabel.frame.width + tagSpacingX
155 + }
156 +
157 + activeCodesCountLabel.text = String(dfyCoupons.count) + " Ενεργοί κωδικοί:"
158 + // activeCodeLabel.text = couponCodesString
159 + activeCodeExpirationLabel.isHidden = true
160 +
161 + // update container view height
162 + activeCodeContentViewHeight.constant = currentOriginY + tagHeight
163 + if ((currentOriginY + tagHeight) <= (2 * tagHeight + tagSpacingY)) {
164 + activeCodeScrollViewHeight.constant = currentOriginY + tagHeight
165 + } else {
166 + activeCodeScrollViewHeight.constant = 2 * tagHeight + tagSpacingY
167 + }
168 + }
169 + } else {
170 + activeCodeLabel.text = "-"
171 + activeCodeExpirationLabel.text = ""
172 +
173 + activeCodeView.isHidden = true
174 +
175 + activeCodeViewHeight.constant = 0
176 + }
15 } 177 }
16 178
17 override func setSelected(_ selected: Bool, animated: Bool) { 179 override func setSelected(_ selected: Bool, animated: Bool) {
......
...@@ -5,19 +5,91 @@ ...@@ -5,19 +5,91 @@
5 // Created by Manos Chorianopoulos on 3/4/23. 5 // Created by Manos Chorianopoulos on 3/4/23.
6 // 6 //
7 7
8 +import Foundation
8 import UIKit 9 import UIKit
9 10
10 class UnifiedCouponsTableViewCell: UITableViewCell { 11 class UnifiedCouponsTableViewCell: UITableViewCell {
12 + @IBOutlet weak var couponBgImage: UIImageView!
13 + @IBOutlet weak var couponImage: UIImageView!
14 + @IBOutlet weak var borderView: UIView!
15 + @IBOutlet weak var nameLabel: UILabel!
16 + @IBOutlet weak var dicountLabel: UILabel!
17 + @IBOutlet weak var discriptionLabel: UILabel!
18 + @IBOutlet weak var expirationLabel: UILabel!
11 19
12 - override func awakeFromNib() { 20 + var postImageURL: String? {
21 + didSet {
22 + if let url = postImageURL {
23 + self.couponImage.image = UIImage() // UIImage(named: "loading")
24 +
25 + UIImage.loadImageUsingCacheWithUrlString(url) { image in
26 + // set the image only when we are still displaying the content for the image we finished downloading
27 + if url == self.postImageURL {
28 + self.couponImage.image = image
29 + }
30 + }
31 + }
32 + else {
33 + self.couponImage.image = nil
34 + }
35 + }
36 + }
37 +
38 +
39 + public override func awakeFromNib() {
13 super.awakeFromNib() 40 super.awakeFromNib()
14 // Initialization code 41 // Initialization code
42 +
43 + couponBgImage.image = UIImage(named: "coupon_bg", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
44 +
45 + borderView.addDashedBorderVertical(color: UIColor(red: 0.44, green: 0.44, blue: 0.44, alpha: 1.00), width: 1.0, height: 110.0)
15 } 46 }
16 47
17 - override func setSelected(_ selected: Bool, animated: Bool) { 48 + public override func setSelected(_ selected: Bool, animated: Bool) {
18 super.setSelected(selected, animated: animated) 49 super.setSelected(selected, animated: animated)
19 50
20 // Configure the view for the selected state 51 // Configure the view for the selected state
21 } 52 }
22 53
54 + public override func layoutSubviews() {
55 + super.layoutSubviews()
56 + //set the values for top,left,bottom,right margins
57 + let margins = UIEdgeInsets(top: 0, left: 0, bottom: 8, right: 0)
58 + contentView.frame = contentView.frame.inset(by: margins)
59 + }
60 +
61 +
62 + func configureCell(coupon: swiftApi.CouponItemModel) {
63 +// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price
64 +// COUPON: coupon, expiration, discount, status
65 +// MERCHANT: _img_preview,_admin_name
66 +
67 + let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
68 +
69 + let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data
70 +
71 + nameLabel.text = ""
72 +
73 + for merchant in merchantList {
74 + if (merchant._uuid == couponSetData?.merchant_uuid) {
75 + // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
76 + self.postImageURL = merchant._img_preview
77 + nameLabel.text = merchant._admin_name
78 + break;
79 + }
80 + }
81 +
82 +// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
83 +// nameLabel.text = couponSetData?.name ?? ""
84 + let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€")
85 + : couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%")
86 + : couponSetData?.discount_type == "plus_one" ? "1+1"
87 + : ((coupon.discount ?? "") + "€")
88 + dicountLabel.text = discount
89 + // let htmlText = couponSetData?.inner_text ?? ""
90 + // discriptionLabel.text = htmlText.htmlToString
91 + discriptionLabel.text = couponSetData?.inner_text ?? ""
92 + expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
93 + }
94 +
23 } 95 }
......
...@@ -44,11 +44,23 @@ import SwiftEventBus ...@@ -44,11 +44,23 @@ import SwiftEventBus
44 @IBOutlet weak var activeCodeScrollViewHeight: NSLayoutConstraint! 44 @IBOutlet weak var activeCodeScrollViewHeight: NSLayoutConstraint!
45 @IBOutlet weak var activeCodeContentView: UIView! 45 @IBOutlet weak var activeCodeContentView: UIView!
46 @IBOutlet weak var activeCodeContentViewHeight: NSLayoutConstraint! 46 @IBOutlet weak var activeCodeContentViewHeight: NSLayoutConstraint!
47 + @IBOutlet weak var rewardsView: UIView!
48 + @IBOutlet weak var rewardsLabel: UILabel!
49 + @IBOutlet weak var sumBadgeImage: UIImageView!
50 + @IBOutlet weak var sumBadgeLabel: UILabel!
51 + @IBOutlet weak var dfyBadgeImage: UIImageView!
52 + @IBOutlet weak var dfyBadgeLabel: UILabel!
53 + @IBOutlet weak var couponBadgeImage: UIImageView!
54 + @IBOutlet weak var couponBadgeLabel: UILabel!
55 + @IBOutlet weak var marketBadgeImage: UIImageView!
56 + @IBOutlet weak var marketBadgeLabel: UILabel!
47 57
48 public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList() 58 public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
49 public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() 59 public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
50 public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge() 60 public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
51 public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer() 61 public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
62 + // TODO: Add correct unifiedCoupons
63 + public var unifiedCoupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
52 64
53 var timerWallet: DispatchSourceTimer? 65 var timerWallet: DispatchSourceTimer?
54 var seconds: Int = 0 66 var seconds: Int = 0
...@@ -58,6 +70,30 @@ import SwiftEventBus ...@@ -58,6 +70,30 @@ import SwiftEventBus
58 70
59 self.hidesBottomBarWhenPushed = true 71 self.hidesBottomBarWhenPushed = true
60 72
73 + // TODO: DELETE ===>
74 + // let coupon = swiftApi.ActiveDFYCouponModel()
75 + // coupon._value = "12"
76 + // // coupon._date = "2022-12-05 01:55:01"
77 + // coupon._date = "2022-10-26 23:59:01"
78 + // coupon._code = "123456789"
79 +
80 + // let coupon2 = swiftApi.ActiveDFYCouponModel()
81 + // coupon2._value = "23"
82 + // coupon2._date = "2022-11-05 01:55"
83 + // coupon2._code = "234567891"
84 +
85 + // let coupon3 = swiftApi.ActiveDFYCouponModel()
86 + // coupon3._value = "34"
87 + // coupon3._date = "2022-07-01 01:55"
88 + // coupon3._code = "345678912"
89 +
90 + // let couponsArray: Array<swiftApi.ActiveDFYCouponModel> = [coupon, coupon2, coupon3, coupon3, coupon3]
91 +
92 + // swiftApi().setActiveDFYCoupons(dfyCoupons: couponsArray)
93 +
94 + // dfyCoupons = swiftApi().getActiveDFYCoupons()
95 + // TODO: DELETE <===
96 +
61 setBackButton() 97 setBackButton()
62 setNavigationTitle("My Rewards") 98 setNavigationTitle("My Rewards")
63 99
...@@ -341,7 +377,9 @@ import SwiftEventBus ...@@ -341,7 +377,9 @@ import SwiftEventBus
341 377
342 emptyImage.image = UIImage(named: "ic_empty_wallet", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 378 emptyImage.image = UIImage(named: "ic_empty_wallet", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
343 emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!" 379 emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!"
344 - if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0) { 380 + // TODO: FIX emptyView check
381 +// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0) {
382 + if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0) {
345 emptyView.isHidden = false 383 emptyView.isHidden = false
346 } else { 384 } else {
347 emptyView.isHidden = true 385 emptyView.isHidden = true
...@@ -523,28 +561,162 @@ import SwiftEventBus ...@@ -523,28 +561,162 @@ import SwiftEventBus
523 extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ 561 extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
524 562
525 public func numberOfSections(in tableView: UITableView) -> Int { 563 public func numberOfSections(in tableView: UITableView) -> Int {
526 - return 1 564 + return 3
527 } 565 }
528 566
529 public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 567 public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
568 + if (section == 0) {
569 + // TODO: Dynamic
570 + return 3
571 +// return self.unifiedCoupons.count
572 + } else if (section == 1) {
573 + return 1
574 + }
530 return self.coupons.count 575 return self.coupons.count
531 } 576 }
532 577
533 public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 578 public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
579 + if (indexPath.section == 0) {
580 + if (self.unifiedCoupons.count > 0) {
534 return 120.0 + 8.0 581 return 120.0 + 8.0
535 -// return UITableViewAutomaticDimension 582 + } else {
583 + return 0.0
584 + }
585 + } else if (indexPath.section == 1) {
586 + // TODO: Uncomment
587 + if (self.dfyCoupons.count > 0) {
588 + return UITableView.automaticDimension
589 + } else {
590 + return 0.0
591 + }
592 +
593 + } else {
594 + if (self.coupons.count > 0) {
595 + return 120.0 + 8.0
596 + } else {
597 + return 0.0
598 + }
599 + }
600 + }
601 +
602 + public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
603 + if (section == 0) {
604 + let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 75))
605 + view.backgroundColor = .clear
606 +
607 + let titleLabel = UILabel(frame: CGRect(x: 20, y: 40, width: view.frame.width - 40, height: 21))
608 + titleLabel.font = UIFont(name: "PFSquareSansPro-Medium", size: 21)
609 + titleLabel.textColor = UIColor(rgb: 0xFFFFFF)
610 + titleLabel.text = "COSMOTE SuperMarket Deals"
611 +
612 + view.addSubview(titleLabel)
613 + return view
614 +
615 + } else if (section == 1) {
616 + let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 68))
617 + view.backgroundColor = .clear
618 +
619 + let imageView = UIImageView(frame: CGRect(x: 20, y: 20, width: view.frame.width / 3.5, height: 38))
620 + imageView.contentMode = .scaleAspectFit
621 +
622 + if let dfyHeaderImage = UIImage(named: "dfy_logo_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
623 + imageView.image = dfyHeaderImage
624 + }
625 + view.addSubview(imageView)
626 +
627 + return view
628 +
629 + } else {
630 +// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 71))
631 + let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 65))
632 + view.backgroundColor = .clear
633 +
634 +// let titleLabel = UILabel(frame: CGRect(x: 20, y: 40, width: view.frame.width - 40, height: 21))
635 + let titleLabel = UILabel(frame: CGRect(x: 20, y: 30, width: view.frame.width - 40, height: 21))
636 + titleLabel.font = UIFont(name: "PFSquareSansPro-Medium", size: 21)
637 + titleLabel.textColor = UIColor(rgb: 0xFFFFFF)
638 + titleLabel.text = "Τα δώρα μου"
639 +
640 + view.addSubview(titleLabel)
641 + return view
642 + }
643 + }
644 +
645 + public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
646 + if (section == 0) {
647 + if (self.unifiedCoupons.count > 0) {
648 + return 75.0
649 + } else {
650 + return 0.0
651 + }
652 +
653 + } else if (section == 1) {
654 + if (self.dfyCoupons.count > 0) {
655 + return 68.0
656 + } else {
657 + return 0.0
658 + }
659 +
660 + } else {
661 + if (self.coupons.count > 0) {
662 + return 65.0
663 + } else {
664 + return 0.0
665 + }
666 + }
667 + }
668 +
669 + public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
670 +// return CGFloat.leastNormalMagnitude
671 + return 0.0
672 + }
673 +
674 + public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
675 + return nil
536 } 676 }
537 677
538 public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 678 public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
539 - let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
540 679
680 + if (indexPath.section == 0) {
681 + let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponsTableViewCellId", for: indexPath) as! UnifiedCouponsTableViewCell
541 cell.configureCell(coupon: coupons[indexPath.row]) 682 cell.configureCell(coupon: coupons[indexPath.row])
683 + return cell
542 684
685 + } else if (indexPath.section == 1) {
686 + let cell = tableView.dequeueReusableCell(withIdentifier: "ActiveCodeTableViewCellId", for: indexPath) as! ActiveCodeTableViewCell
687 +// cell.configureCell(coupon: coupons[indexPath.row])
688 + return cell
689 +
690 + } else {
691 + let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
692 + cell.configureCell(coupon: coupons[indexPath.row])
543 return cell 693 return cell
544 } 694 }
695 + }
545 696
546 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 697 public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
698 + if (indexPath.section == 0) {
699 + // TODO: open unified CouponBarcodeViewController
700 +// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
701 +// let couponName = couponSetData?.name ?? ""
702 +// swiftApi().logTrackersEvent("click", ("Coupon:" + couponName))
703 +//
704 +// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
705 +// let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
706 +// vc.coupon = coupons[indexPath.row]
707 +// vc.isFromWallet = true
708 +// self.navigationController?.pushViewController(vc, animated: true)
709 +
710 + } else if (indexPath.section == 1) {
711 + print("Active DFY coupon banner Tapped!")
547 712
713 + swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveDealsBanner"))
714 +
715 + let couponDetails = swiftApi.ActiveDFYCouponEventModel()
716 + couponDetails._isPressed = true
717 + SwiftEventBus.post("dfy_coupon_details", sender: couponDetails)
718 +
719 + } else {
548 let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data 720 let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
549 let couponName = couponSetData?.name ?? "" 721 let couponName = couponSetData?.name ?? ""
550 swiftApi().logTrackersEvent("click", ("Coupon:" + couponName)) 722 swiftApi().logTrackersEvent("click", ("Coupon:" + couponName))
...@@ -554,6 +726,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -554,6 +726,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
554 vc.coupon = coupons[indexPath.row] 726 vc.coupon = coupons[indexPath.row]
555 vc.isFromWallet = true 727 vc.isFromWallet = true
556 self.navigationController?.pushViewController(vc, animated: true) 728 self.navigationController?.pushViewController(vc, animated: true)
729 + }
557 730
558 } 731 }
559 } 732 }
......