Manos Chorianopoulos

market history fixes

...@@ -34,16 +34,41 @@ class AnalysisHeaderMessageViewCell: UITableViewCell { ...@@ -34,16 +34,41 @@ class AnalysisHeaderMessageViewCell: UITableViewCell {
34 messageLabel.layer.borderColor = UIColor(rgb: 0x1DA6B9).cgColor 34 messageLabel.layer.borderColor = UIColor(rgb: 0x1DA6B9).cgColor
35 messageLabel.layer.cornerRadius = 5 35 messageLabel.layer.cornerRadius = 5
36 36
37 - let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100) 37 +// messageLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
38 +
39 + }
40 +}
41 +
42 +extension AnalysisHeaderMessageViewCell {
43 + func configureCell(isEmpty: Bool, isMarket: Bool) {
44 +
45 + if (isEmpty == true) {
46 + emptyLabel.isHidden = false
47 + } else {
48 + emptyLabel.isHidden = true
49 + }
50 +
51 + if (isMarket == true) {
52 + itemImage.image = UIImage(named: "ic_history_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
53 +
54 + let oldUnifiedCouponList: Array<swiftApi.CouponItemModel> = swiftApi().getOldUnifiedCouponList()
55 + let oldUnifiedCouponListLength = oldUnifiedCouponList.count
56 + var unifiedCouponsDiscount: Float = 0.0
57 +
58 + for coupon in oldUnifiedCouponList {
59 + if let discountFloat = Float(coupon.discount ?? "0.0") {
60 + unifiedCouponsDiscount += discountFloat
61 + }
62 + }
63 +
64 + let totalCouponDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
38 var totalCouponDiscountString = "0" 65 var totalCouponDiscountString = "0"
39 totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) 66 totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
40 67
41 -// messageLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
42 -
43 let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει " 68 let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
44 let coupBoldText = totalCouponDiscountString + "€" 69 let coupBoldText = totalCouponDiscountString + "€"
45 let coupNormalText2 = " σε προσφορές από " 70 let coupNormalText2 = " σε προσφορές από "
46 - let coupBoldText2 = String(loyaltyBadge._couponCount) 71 + let coupBoldText2 = String(oldUnifiedCouponListLength)
47 let coupNormalText3 = " κουπόνια!" 72 let coupNormalText3 = " κουπόνια!"
48 73
49 let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PFSquareSansPro-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16)] 74 let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PFSquareSansPro-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16)]
...@@ -60,22 +85,34 @@ class AnalysisHeaderMessageViewCell: UITableViewCell { ...@@ -60,22 +85,34 @@ class AnalysisHeaderMessageViewCell: UITableViewCell {
60 coupAttributedString.append(coupBoldString2) 85 coupAttributedString.append(coupBoldString2)
61 coupAttributedString.append(coupNormalString3) 86 coupAttributedString.append(coupNormalString3)
62 messageLabel.attributedText = coupAttributedString 87 messageLabel.attributedText = coupAttributedString
63 - }
64 -}
65 -
66 -extension AnalysisHeaderMessageViewCell {
67 - func configureCell(isEmpty: Bool, isMarket: Bool) {
68 88
69 - if (isEmpty == true) {
70 - emptyLabel.isHidden = false
71 - } else {
72 - emptyLabel.isHidden = true
73 - }
74 -
75 - if (isMarket == true) {
76 - itemImage.image = UIImage(named: "ic_history_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
77 } else { 89 } else {
78 itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 90 itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
91 +
92 + let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
93 + var totalCouponDiscountString = "0"
94 + totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
95 +
96 + let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
97 + let coupBoldText = totalCouponDiscountString + "€"
98 + let coupNormalText2 = " σε προσφορές από "
99 + let coupBoldText2 = String(loyaltyBadge._couponCount)
100 + let coupNormalText3 = " κουπόνια!"
101 +
102 + let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PFSquareSansPro-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16)]
103 + let attrBold = [NSAttributedString.Key.font : UIFont(name: "PFSquareSansPro-Bold", size: 17) ?? UIFont.boldSystemFont(ofSize: 16)]
104 +
105 + let coupAttributedString = NSMutableAttributedString(string:coupNormalText1, attributes:attrRegular)
106 + let coupBoldString = NSMutableAttributedString(string: coupBoldText, attributes:attrBold)
107 + let coupNormalString2 = NSMutableAttributedString(string:coupNormalText2, attributes:attrRegular)
108 + let coupBoldString2 = NSMutableAttributedString(string: coupBoldText2, attributes:attrBold)
109 + let coupNormalString3 = NSMutableAttributedString(string:coupNormalText3, attributes:attrRegular)
110 +
111 + coupAttributedString.append(coupBoldString)
112 + coupAttributedString.append(coupNormalString2)
113 + coupAttributedString.append(coupBoldString2)
114 + coupAttributedString.append(coupNormalString3)
115 + messageLabel.attributedText = coupAttributedString
79 } 116 }
80 117
81 } 118 }
......
...@@ -118,4 +118,42 @@ extension AnalysisItemViewCell { ...@@ -118,4 +118,42 @@ extension AnalysisItemViewCell {
118 // subtitleLabel.text = htmlText.htmlToString 118 // subtitleLabel.text = htmlText.htmlToString
119 119
120 } 120 }
121 +
122 + func configureCell(item: swiftApi.CouponItemModel, isMarket: Bool) {
123 +
124 +// COUPONSET: desc, img_preview, name, terms, merchant_uuid
125 +// COUPON: coupon, expiration, discount, status
126 +// MERCHANT: _img_preview,_admin_name
127 +
128 +// let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
129 +// let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
130 +//
131 +// titleLabel.text = ""
132 +//
133 +// for merchant in merchantList {
134 +// if (merchant._uuid == couponSetData?.merchant_uuid) {
135 +// // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
136 +// self.postImageURL = merchant._img_preview
137 +// titleLabel.text = merchant._admin_name
138 +// break;
139 +// }
140 +// }
141 +
142 + titleLabel.text = item.name
143 + self.postImageURL = item.image
144 +
145 + dateLabel.text = item.redeemed ?? ""
146 +
147 + let priceFloat = Float(round(100 * (Float(item.discount ?? "0.0") ?? 0.0 )) / 100)
148 + var priceString = "0"
149 + priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
150 + priceLabel.text = priceString + "€"
151 +
152 + subtitleLabel.text = "Έκπτωτικό κουπόνι"
153 +// subtitleLabel.text = couponSetData?.short_description ?? ""
154 + // OR
155 +// let htmlText = couponSetData?.inner_text ?? ""
156 +// subtitleLabel.text = htmlText.htmlToString
157 +
158 + }
121 } 159 }
......
...@@ -524,7 +524,7 @@ ...@@ -524,7 +524,7 @@
524 <scene sceneID="Unf-jQ-yhe"> 524 <scene sceneID="Unf-jQ-yhe">
525 <objects> 525 <objects>
526 <tableViewController storyboardIdentifier="MarketSharingHistoryViewController" id="R2a-Tw-n8n" customClass="MarketSharingHistoryViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController"> 526 <tableViewController storyboardIdentifier="MarketSharingHistoryViewController" id="R2a-Tw-n8n" customClass="MarketSharingHistoryViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController">
527 - <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="CQc-tP-sD3"> 527 + <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="CQc-tP-sD3">
528 <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> 528 <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
529 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 529 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
530 <color key="backgroundColor" systemColor="systemBackgroundColor"/> 530 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
...@@ -746,7 +746,7 @@ ...@@ -746,7 +746,7 @@
746 <scene sceneID="33f-Co-X5F"> 746 <scene sceneID="33f-Co-X5F">
747 <objects> 747 <objects>
748 <tableViewController storyboardIdentifier="MarketHistoryViewController" id="iFj-6f-ytl" customClass="MarketHistoryViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController"> 748 <tableViewController storyboardIdentifier="MarketHistoryViewController" id="iFj-6f-ytl" customClass="MarketHistoryViewController" customModule="SwiftWarplyFramework" customModuleProvider="target" sceneMemberID="viewController">
749 - <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="Ruu-TU-GVv"> 749 + <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="Ruu-TU-GVv">
750 <rect key="frame" x="0.0" y="0.0" width="414" height="896"/> 750 <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
751 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 751 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
752 <color key="backgroundColor" systemColor="systemBackgroundColor"/> 752 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
......
...@@ -9,7 +9,7 @@ import UIKit ...@@ -9,7 +9,7 @@ import UIKit
9 9
10 class MarketHistoryViewController: AnalysisChildViewController { 10 class MarketHistoryViewController: AnalysisChildViewController {
11 var loading: Bool = false 11 var loading: Bool = false
12 - var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldCouponList() 12 + var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldUnifiedCouponList()
13 var showMore = false 13 var showMore = false
14 14
15 // TODO: remove this when configuring model 15 // TODO: remove this when configuring model
...@@ -38,7 +38,7 @@ class MarketHistoryViewController: AnalysisChildViewController { ...@@ -38,7 +38,7 @@ class MarketHistoryViewController: AnalysisChildViewController {
38 38
39 showLoading() 39 showLoading()
40 40
41 - items = swiftApi().getOldCouponList() 41 + items = swiftApi().getOldUnifiedCouponList()
42 42
43 self.showMore = (self.items.count > 3) 43 self.showMore = (self.items.count > 3)
44 44
...@@ -131,7 +131,7 @@ class MarketHistoryViewController: AnalysisChildViewController { ...@@ -131,7 +131,7 @@ class MarketHistoryViewController: AnalysisChildViewController {
131 } 131 }
132 132
133 let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell 133 let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
134 - cell.configureCell(item: items[indexPath.row]) 134 + cell.configureCell(item: items[indexPath.row], isMarket: true)
135 135
136 return cell 136 return cell
137 } 137 }
...@@ -142,7 +142,7 @@ class MarketHistoryViewController: AnalysisChildViewController { ...@@ -142,7 +142,7 @@ class MarketHistoryViewController: AnalysisChildViewController {
142 } 142 }
143 143
144 if (self.showMore && indexPath.row == 3) { 144 if (self.showMore && indexPath.row == 3) {
145 - self.items = swiftApi().getOldCouponList() 145 + self.items = swiftApi().getOldUnifiedCouponList()
146 self.showMore = false 146 self.showMore = false
147 self.tableView.reloadData() 147 self.tableView.reloadData()
148 } 148 }
......
...@@ -118,7 +118,7 @@ import SwiftEventBus ...@@ -118,7 +118,7 @@ import SwiftEventBus
118 if (index == 1) { 118 if (index == 1) {
119 swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabShared")) 119 swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabShared"))
120 120
121 - let analysisVC = storyboard.instantiateViewController(withIdentifier:"SharingHistoryViewController") as! SwiftWarplyFramework.SharingHistoryViewController 121 + let analysisVC = storyboard.instantiateViewController(withIdentifier:"MarketSharingHistoryViewController") as! SwiftWarplyFramework.MarketSharingHistoryViewController
122 analysisVC.index = index; 122 analysisVC.index = index;
123 123
124 return analysisVC; 124 return analysisVC;
...@@ -126,7 +126,7 @@ import SwiftEventBus ...@@ -126,7 +126,7 @@ import SwiftEventBus
126 126
127 swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabExpired")) 127 swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabExpired"))
128 128
129 - let analysisVC = storyboard.instantiateViewController(withIdentifier:"HistoryViewController") as! SwiftWarplyFramework.HistoryViewController 129 + let analysisVC = storyboard.instantiateViewController(withIdentifier:"MarketHistoryViewController") as! SwiftWarplyFramework.MarketHistoryViewController
130 analysisVC.index = index; 130 analysisVC.index = index;
131 131
132 return analysisVC; 132 return analysisVC;
......
...@@ -523,15 +523,12 @@ import SwiftEventBus ...@@ -523,15 +523,12 @@ import SwiftEventBus
523 } 523 }
524 524
525 func updateMarketBadge() { 525 func updateMarketBadge() {
526 - for uniCoupon in self.unifiedCoupons { 526 + unifiedCouponsDiscount = 0.0
527 - for coupon in uniCoupon._coupons { 527 + for coupon in swiftApi().getOldUnifiedCouponList() {
528 - if (coupon.status == 1) {
529 if let discountFloat = Float(coupon.discount ?? "0.0") { 528 if let discountFloat = Float(coupon.discount ?? "0.0") {
530 unifiedCouponsDiscount += discountFloat 529 unifiedCouponsDiscount += discountFloat
531 } 530 }
532 } 531 }
533 - }
534 - }
535 532
536 if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) { 533 if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
537 emptyView.isHidden = false 534 emptyView.isHidden = false
...@@ -642,6 +639,18 @@ import SwiftEventBus ...@@ -642,6 +639,18 @@ import SwiftEventBus
642 @IBAction func marketBadgeButtonAction(_ sender: Any) { 639 @IBAction func marketBadgeButtonAction(_ sender: Any) {
643 print("Market Badge pressed!") 640 print("Market Badge pressed!")
644 // TODO: add action - open marketHistory after check 641 // TODO: add action - open marketHistory after check
642 + if (self.unifiedCouponsDiscount > 0.0) {
643 +// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
644 +// firebaseEvent._eventName = "did_tap_deals_for_you_badge"
645 +// firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
646 +// SwiftEventBus.post("firebase", sender: firebaseEvent)
647 +
648 +// swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyBanner"))
649 +
650 + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
651 + let vc = storyboard.instantiateViewController(withIdentifier: "MarketLoyaltyAnalysisViewController") as! SwiftWarplyFramework.MarketLoyaltyAnalysisViewController
652 + self.navigationController?.pushViewController(vc, animated: true)
653 + }
645 } 654 }
646 655
647 } 656 }
......
...@@ -18,6 +18,7 @@ public struct GlobalVariables { ...@@ -18,6 +18,7 @@ public struct GlobalVariables {
18 static var oldCouponList: Array<swiftApi.CouponItemModel> = [] 18 static var oldCouponList: Array<swiftApi.CouponItemModel> = []
19 static var couponSetList: Array<swiftApi.CouponSetItemModel> = [] 19 static var couponSetList: Array<swiftApi.CouponSetItemModel> = []
20 static var unifiedCouponList: Array<swiftApi.UnifiedCouponModel> = [] 20 static var unifiedCouponList: Array<swiftApi.UnifiedCouponModel> = []
21 + static var oldUnifiedCouponList: Array<swiftApi.CouponItemModel> = []
21 static var loyaltyBadge: swiftApi.LoyaltyBadgeModel = swiftApi.LoyaltyBadgeModel() 22 static var loyaltyBadge: swiftApi.LoyaltyBadgeModel = swiftApi.LoyaltyBadgeModel()
22 static var consumer: swiftApi.ProfileModel? 23 static var consumer: swiftApi.ProfileModel?
23 static var consumerInternal: swiftApi.ProfileModel? 24 static var consumerInternal: swiftApi.ProfileModel?
...@@ -153,6 +154,16 @@ public class swiftApi { ...@@ -153,6 +154,16 @@ public class swiftApi {
153 } 154 }
154 155
155 156
157 + public func setOldUnifiedCouponList(_ coupons: Array<CouponItemModel>) {
158 + GlobalVariables.oldUnifiedCouponList = coupons
159 + }
160 +
161 +
162 + public func getOldUnifiedCouponList() -> Array<CouponItemModel> {
163 + return GlobalVariables.oldUnifiedCouponList
164 + }
165 +
166 +
156 public func startTrackingSteps(_ getStepsCallback: @escaping (_ steps: Int) -> Void) -> Void { 167 public func startTrackingSteps(_ getStepsCallback: @escaping (_ steps: Int) -> Void) -> Void {
157 168
158 if (GlobalVariables.trackingStepsEnabled == false) { 169 if (GlobalVariables.trackingStepsEnabled == false) {
...@@ -6852,6 +6863,7 @@ public class swiftApi { ...@@ -6852,6 +6863,7 @@ public class swiftApi {
6852 6863
6853 func getUnifiedCallback(_ responseData: [AnyHashable: Any]?) -> Void { 6864 func getUnifiedCallback(_ responseData: [AnyHashable: Any]?) -> Void {
6854 var unifiedCouponsArray:Array<UnifiedCouponModel> = [] 6865 var unifiedCouponsArray:Array<UnifiedCouponModel> = []
6866 + var oldUnifiedCouponsArray:Array<CouponItemModel> = []
6855 6867
6856 if let responseDataDictionary = responseData as? [String: AnyObject] { 6868 if let responseDataDictionary = responseData as? [String: AnyObject] {
6857 6869
...@@ -6868,14 +6880,25 @@ public class swiftApi { ...@@ -6868,14 +6880,25 @@ public class swiftApi {
6868 if let itemDictionary = item { 6880 if let itemDictionary = item {
6869 if let itemDictionaryStauts = itemDictionary["status"] as? String { 6881 if let itemDictionaryStauts = itemDictionary["status"] as? String {
6870 if (itemDictionaryStauts == "active") { 6882 if (itemDictionaryStauts == "active") {
6871 - let tempCampaign = UnifiedCouponModel(dictionary: itemDictionary) 6883 + let tempUniCoupon = UnifiedCouponModel(dictionary: itemDictionary)
6872 - unifiedCouponsArray.append(tempCampaign) 6884 + unifiedCouponsArray.append(tempUniCoupon)
6873 } 6885 }
6886 +
6887 + // Old Unified Coupons
6888 + let tempUniCoupon = UnifiedCouponModel(dictionary: itemDictionary)
6889 +
6890 + for item in tempUniCoupon._coupons {
6891 + if (item.status == 0) {
6892 + oldUnifiedCouponsArray.append(item)
6893 + }
6894 + }
6895 +
6874 } 6896 }
6875 } 6897 }
6876 } 6898 }
6877 6899
6878 swiftApi().setUnifiedCouponList(unifiedCouponsArray) 6900 swiftApi().setUnifiedCouponList(unifiedCouponsArray)
6901 + swiftApi().setOldUnifiedCouponList(oldUnifiedCouponsArray)
6879 successCallback(unifiedCouponsArray) 6902 successCallback(unifiedCouponsArray)
6880 } 6903 }
6881 } else { 6904 } else {
......