Showing
6 changed files
with
384 additions
and
16 deletions
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
... | @@ -5,25 +5,351 @@ | ... | @@ -5,25 +5,351 @@ |
5 | // Created by Manos Chorianopoulos on 25/10/23. | 5 | // Created by Manos Chorianopoulos on 25/10/23. |
6 | // | 6 | // |
7 | 7 | ||
8 | +import Foundation | ||
8 | import UIKit | 9 | import UIKit |
10 | +import SwiftEventBus | ||
9 | 11 | ||
10 | @objc public class LoyaltyHistoryViewController: UIViewController { | 12 | @objc public class LoyaltyHistoryViewController: UIViewController { |
13 | + @IBOutlet weak var sectionTitleLabel: UILabel! | ||
14 | + @IBOutlet weak var historySectionView: UIView! | ||
15 | + | ||
16 | + @IBOutlet weak var sumBadgeImage: UIImageView! | ||
17 | + @IBOutlet weak var sumBadgeLabel: UILabel! | ||
18 | + @IBOutlet weak var sumBannerLabel: UILabel! | ||
19 | + | ||
20 | + @IBOutlet weak var dfyBannerParentView: UIView! | ||
21 | + @IBOutlet weak var dfyBannerInnerParentView: UIView! | ||
22 | + @IBOutlet weak var dfyBannerInnerView: UIView! | ||
23 | + @IBOutlet weak var dfyBadgeImage: UIImageView! | ||
24 | + @IBOutlet weak var dfyBadgeLabel: UILabel! | ||
25 | + @IBOutlet weak var dfyBannerLabel: UILabel! | ||
26 | + | ||
27 | + @IBOutlet weak var marketBannerParentView: UIView! | ||
28 | + @IBOutlet weak var marketBannerInnerView: UIView! | ||
29 | + @IBOutlet weak var marketBadgeImage: UIImageView! | ||
30 | + @IBOutlet weak var marketBadgeLabel: UILabel! | ||
31 | + @IBOutlet weak var marketBannerLabel: UILabel! | ||
32 | + | ||
33 | + @IBOutlet weak var gfyBannerParentView: UIView! | ||
34 | + @IBOutlet weak var gfyBannerInnerView: UIView! | ||
35 | + @IBOutlet weak var couponBadgeImage: UIImageView! | ||
36 | + @IBOutlet weak var couponBadgeLabel: UILabel! | ||
37 | + @IBOutlet weak var gfyBannerLabel: UILabel! | ||
38 | + | ||
39 | + public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList() | ||
40 | + public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() | ||
41 | + public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = [] | ||
42 | + public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge() | ||
43 | + | ||
44 | + var totalCouponValue = swiftApi().getDealsCouponsSum() | ||
45 | + var totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100) | ||
46 | + var unifiedCouponsDiscount:Float = 0.0 | ||
47 | + | ||
11 | 48 | ||
12 | public override func viewDidLoad() { | 49 | public override func viewDidLoad() { |
13 | super.viewDidLoad() | 50 | super.viewDidLoad() |
14 | 51 | ||
15 | - // Do any additional setup after loading the view. | 52 | + self.hidesBottomBarWhenPushed = true |
53 | + | ||
54 | + SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in | ||
55 | + | ||
56 | + DispatchQueue.main.async { | ||
57 | + self.coupons = swiftApi().getCouponList() | ||
58 | + self.totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100) | ||
59 | + self.loyaltyBadge = swiftApi().getLoyaltyBadge() | ||
60 | +// self.tableView.reloadData() | ||
61 | + self.updateUI() | ||
62 | + } | ||
63 | + } | ||
64 | + | ||
65 | + SwiftEventBus.onBackgroundThread(self, name: "unified_coupons_fetched") { result in | ||
66 | + | ||
67 | + DispatchQueue.main.async { | ||
68 | + self.unifiedCoupons = swiftApi().getUnifiedCouponList() | ||
69 | + | ||
70 | + self.matchOldSMCoupons() | ||
71 | + self.updateMarketBadge() | ||
72 | +// self.tableView.reloadData() | ||
73 | + self.updateUI() | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + setBackButton() | ||
78 | + setNavigationTitle("Ιστορικό") | ||
79 | + | ||
80 | + // === images === // | ||
81 | + | ||
82 | + sumBadgeImage.image = UIImage(named: "history_heart", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
83 | + dfyBadgeImage.image = UIImage(named: "history_banner_dfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
84 | + marketBadgeImage.image = UIImage(named: "history_banner_sm", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
85 | + couponBadgeImage.image = UIImage(named: "history_banner_gfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
86 | + | ||
87 | + sectionTitleLabel.text = "Εξαργυρωμένα κουπόνια" | ||
88 | + | ||
89 | + historySectionView.backgroundColor = .white | ||
90 | + historySectionView.layer.cornerRadius = 16.0 | ||
91 | + // historySectionView.layer.borderWidth = 1 | ||
92 | + // historySectionView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor | ||
93 | + | ||
94 | + // Add shadow | ||
95 | + historySectionView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor | ||
96 | + historySectionView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) | ||
97 | + historySectionView.layer.shadowOpacity = 1.0 | ||
98 | + historySectionView.layer.shadowRadius = 1.0 | ||
99 | + | ||
100 | + } | ||
101 | + | ||
102 | + public override func viewWillAppear(_ animated: Bool) { | ||
103 | + super.viewWillAppear(animated) | ||
104 | + | ||
105 | + swiftApi().logTrackersEvent("screen", "LoyaltyHistoryScreen") | ||
106 | + | ||
107 | + // addNavShadow() | ||
108 | + self.navigationController?.hideHairline() | ||
109 | + | ||
110 | + self.coupons = swiftApi().getCouponList() | ||
111 | + self.unifiedCoupons = swiftApi().getUnifiedCouponList() | ||
112 | + self.dfyCoupons = swiftApi().getActiveDFYCoupons() | ||
113 | + | ||
114 | + self.matchOldSMCoupons() | ||
115 | + self.updateMarketBadge() | ||
116 | +// self.tableView.reloadData() | ||
117 | + self.updateUI() | ||
118 | + } | ||
119 | + | ||
120 | +// public override func viewWillDisappear(_ animated: Bool) { | ||
121 | +// super.viewWillDisappear(animated) | ||
122 | +// | ||
123 | +// self.navigationController?.navigationBar.layer.shadowOpacity = 0.0 | ||
124 | +// | ||
125 | +// } | ||
126 | + | ||
127 | + // MARK: - Functions | ||
128 | + func updateMarketBadge() { | ||
129 | + unifiedCouponsDiscount = 0.0 | ||
130 | +// for smCouponSet in swiftApi().getCouponSetsDealsList() { | ||
131 | +// for oldCoupon in swiftApi().getAllOldCouponList() { | ||
132 | +// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) { | ||
133 | +// | ||
134 | +// oldCoupon.setCouponSetData(smCouponSet); | ||
135 | +// | ||
136 | +// if let discountFloat = Float(oldCoupon.discount ?? "0.0") { | ||
137 | +// unifiedCouponsDiscount += discountFloat | ||
138 | +// } | ||
139 | +// break; | ||
140 | +// } | ||
141 | +// } | ||
142 | +// } | ||
143 | + | ||
144 | + for coupon in swiftApi().getOldUnifiedCouponList() { | ||
145 | + if let discountFloat = Float(coupon.discount ?? "0.0") { | ||
146 | + unifiedCouponsDiscount += discountFloat | ||
147 | + } | ||
148 | + } | ||
149 | + | ||
150 | + // TODO: UNCOMMENT if emptyView is needed again | ||
151 | +// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) { | ||
152 | +// emptyView.isHidden = false | ||
153 | +// emptyViewHeight.constant = emptyView.intrinsicContentSize.height | ||
154 | +// } else { | ||
155 | +// emptyView.isHidden = true | ||
156 | +// emptyViewHeight.constant = 0 | ||
157 | +// } | ||
158 | + } | ||
159 | + | ||
160 | + func matchOldSMCoupons() { | ||
161 | + var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = [] | ||
162 | + | ||
163 | + for smCouponSet in swiftApi().getCouponSetsDealsList() { | ||
164 | + for oldCoupon in swiftApi().getAllOldCouponList() { | ||
165 | + if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) { | ||
166 | + | ||
167 | + oldCoupon.setCouponSetData(smCouponSet); | ||
168 | + oldUnifiedCouponsArray.append(oldCoupon); | ||
169 | + | ||
170 | + break; | ||
171 | + } | ||
172 | + } | ||
173 | + } | ||
174 | + | ||
175 | + oldUnifiedCouponsArray.sort(by: { | ||
176 | + let date1 = $0.redeemed_date | ||
177 | + let date2 = $1.redeemed_date | ||
178 | + | ||
179 | + if ((date1 != nil) && (date2 != nil)) { | ||
180 | + return date1!.compare(date2!) == .orderedDescending | ||
181 | + } else { | ||
182 | + return false | ||
183 | + } | ||
184 | + | ||
185 | + }) | ||
186 | + swiftApi().setOldUnifiedCouponList(oldUnifiedCouponsArray) | ||
187 | + } | ||
188 | + | ||
189 | + func updateUI() { | ||
190 | + let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 14) ?? UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)] | ||
191 | + let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-SBold", size: 14) ?? UIFont.boldSystemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)] | ||
192 | + | ||
193 | + // === SUM banner === // | ||
194 | + | ||
195 | + let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount | ||
196 | + | ||
197 | +// sumRewards = Float(round(100 * sumRewards) / 100) | ||
198 | + var sumRewardsString = "0" | ||
199 | + sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) | ||
200 | + sumBadgeLabel.text = sumRewardsString + "€" | ||
201 | + | ||
202 | + sumBannerLabel.text = "Δες αναλυτικά το συνολικό όφελός σου έως τώρα από κουπόνια" | ||
203 | + | ||
204 | + // === DFY banner === // | ||
205 | + | ||
206 | + dfyBannerParentView.backgroundColor = .clear | ||
207 | + dfyBannerInnerParentView.backgroundColor = .white | ||
208 | + dfyBannerInnerView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05) | ||
209 | + dfyBannerInnerParentView.layer.cornerRadius = 16.0 | ||
210 | + dfyBannerInnerView.layer.cornerRadius = 16.0 | ||
211 | + // dfyBannerInnerView.layer.borderWidth = 1 | ||
212 | + // dfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor | ||
213 | + | ||
214 | + dfyBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor | ||
215 | + dfyBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) | ||
216 | + dfyBannerParentView.layer.shadowOpacity = 1.0 | ||
217 | + dfyBannerParentView.layer.shadowRadius = 1.0 | ||
218 | + | ||
219 | + let totalCouponValueFixed = Float(round(100 * totalCouponValue) / 100) | ||
220 | + var totalCouponValueString = "0" | ||
221 | + totalCouponValueString = String(format: "%.2f", totalCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) | ||
222 | + dfyBadgeLabel.text = totalCouponValueString + "€" | ||
223 | + | ||
224 | + let dfyNormalText1 = "Μέχρι τώρα έχεις όφελος " | ||
225 | + let dfyBoldText = totalCouponValueString + "€" | ||
226 | + let dfyNormalText2 = " από τα DEALS FOR YOU" | ||
227 | + | ||
228 | + let dfyAttributedString = NSMutableAttributedString(string:dfyNormalText1, attributes:attrRegular) | ||
229 | + let dfyBoldString = NSMutableAttributedString(string: dfyBoldText, attributes:attrBold) | ||
230 | + let dfyNormalString = NSMutableAttributedString(string:dfyNormalText2, attributes:attrRegular) | ||
231 | + | ||
232 | + dfyAttributedString.append(dfyBoldString) | ||
233 | + dfyAttributedString.append(dfyNormalString) | ||
234 | + dfyBannerLabel.attributedText = dfyAttributedString | ||
235 | + | ||
236 | + // === MARKET banner === // | ||
237 | + | ||
238 | + marketBannerParentView.backgroundColor = .clear | ||
239 | + marketBannerInnerView.backgroundColor = UIColor(red: 1.00, green: 0.99, blue: 0.97, alpha: 1.00) | ||
240 | + marketBannerInnerView.layer.cornerRadius = 16.0 | ||
241 | + // marketBannerInnerView.layer.borderWidth = 1 | ||
242 | + // marketBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor | ||
243 | + | ||
244 | + marketBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor | ||
245 | + marketBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) | ||
246 | + marketBannerParentView.layer.shadowOpacity = 1.0 | ||
247 | + marketBannerParentView.layer.shadowRadius = 1.0 | ||
248 | + | ||
249 | + let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100) | ||
250 | + var marketDiscountString = "0" | ||
251 | + marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) | ||
252 | + | ||
253 | + self.marketBadgeLabel.text = marketDiscountString + "€" | ||
254 | + | ||
255 | + let marketNormalText1 = "Μέχρι τώρα έχεις όφελος " | ||
256 | + let marketBoldText = marketDiscountString + "€" | ||
257 | + let marketNormalText2 = " από τα SUPERMARKET DEALS!" | ||
258 | + | ||
259 | + let marketAttributedString = NSMutableAttributedString(string:marketNormalText1, attributes:attrRegular) | ||
260 | + let marketBoldString = NSMutableAttributedString(string: marketBoldText, attributes:attrBold) | ||
261 | + let marketNormalString = NSMutableAttributedString(string:marketNormalText2, attributes:attrRegular) | ||
262 | + | ||
263 | + marketAttributedString.append(marketBoldString) | ||
264 | + marketAttributedString.append(marketNormalString) | ||
265 | + marketBannerLabel.attributedText = marketAttributedString | ||
266 | + | ||
267 | + // === GFY banner === // | ||
268 | + | ||
269 | + gfyBannerParentView.backgroundColor = .clear | ||
270 | + gfyBannerInnerView.backgroundColor = UIColor(red: 0.96, green: 0.97, blue: 0.98, alpha: 1.00) | ||
271 | + gfyBannerInnerView.layer.cornerRadius = 16.0 | ||
272 | + // gfyBannerInnerView.layer.borderWidth = 1 | ||
273 | + // gfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor | ||
274 | + | ||
275 | + gfyBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor | ||
276 | + gfyBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) | ||
277 | + gfyBannerParentView.layer.shadowOpacity = 1.0 | ||
278 | + gfyBannerParentView.layer.shadowRadius = 1.0 | ||
279 | + | ||
280 | + var totalCouponDiscountString = "0" | ||
281 | + totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) | ||
282 | + couponBadgeLabel.text = totalCouponDiscountString + "€" | ||
283 | + | ||
284 | + let gfyNormalText1 = "Μέχρι τώρα έχεις όφελος " | ||
285 | + let gfyBoldText = totalCouponDiscountString + "€" | ||
286 | + let gfyNormalText2 = " από τα GIFTS FOR YOU" | ||
287 | + | ||
288 | + let gfyAttributedString = NSMutableAttributedString(string:gfyNormalText1, attributes:attrRegular) | ||
289 | + let gfyBoldString = NSMutableAttributedString(string: gfyBoldText, attributes:attrBold) | ||
290 | + let gfyNormalString = NSMutableAttributedString(string:gfyNormalText2, attributes:attrRegular) | ||
291 | + | ||
292 | + gfyAttributedString.append(gfyBoldString) | ||
293 | + gfyAttributedString.append(gfyNormalString) | ||
294 | + gfyBannerLabel.attributedText = gfyAttributedString | ||
16 | } | 295 | } |
17 | 296 | ||
297 | + // MARK: - Actions | ||
298 | + @IBAction func dfyBannerButtonAction(_ sender: Any) { | ||
299 | + var totalCouponValue = swiftApi().getDealsCouponsSum() | ||
300 | + if (totalCouponValue > 0.0) { | ||
301 | + print("DFY coupon banner pressed!") | ||
302 | + // analysis_pressed event | ||
303 | + let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel() | ||
304 | + dealsAnalysis._isPressed = true | ||
305 | + SwiftEventBus.post("analysis_pressed", sender: dealsAnalysis) | ||
306 | + | ||
307 | +// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
308 | +// firebaseEvent._eventName = "did_tap_gifts_for_you_badge" | ||
309 | +// firebaseEvent.setParameter = ("screen", "Loyalty History") | ||
310 | +// SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
18 | 311 | ||
19 | - /* | 312 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() |
20 | - // MARK: - Navigation | 313 | + firebaseEvent._eventName = "did_tap_deals_for_you_badge" |
314 | + firebaseEvent.setParameter = ("screen", "Loyalty History") | ||
315 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
21 | 316 | ||
22 | - // In a storyboard-based application, you will often want to do a little preparation before navigation | 317 | + swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "DealsBanner")) |
23 | - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
24 | - // Get the new view controller using segue.destination. | ||
25 | - // Pass the selected object to the new view controller. | ||
26 | } | 318 | } |
27 | - */ | 319 | + } |
320 | + | ||
321 | + @IBAction func gfyBannerButtonAction(_ sender: Any) { | ||
322 | + if (loyaltyBadge._couponCount > 0) { | ||
323 | +// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
324 | +// firebaseEvent._eventName = "did_tap_deals_for_you_badge" | ||
325 | +// firebaseEvent.setParameter = ("screen", "Loyalty History") | ||
326 | +// SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
327 | + | ||
328 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
329 | + firebaseEvent._eventName = "did_tap_gifts_for_you_badge" | ||
330 | + firebaseEvent.setParameter = ("screen", "Loyalty History") | ||
331 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
28 | 332 | ||
333 | + swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "LoyaltyBanner")) | ||
334 | + | ||
335 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
336 | + let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyAnalysisViewController") as! SwiftWarplyFramework.LoyaltyAnalysisViewController | ||
337 | + self.navigationController?.pushViewController(vc, animated: true) | ||
338 | + } | ||
339 | + } | ||
340 | + | ||
341 | + @IBAction func marketBannerButtonAction(_ sender: Any) { | ||
342 | + if (self.unifiedCouponsDiscount > 0.0) { | ||
343 | + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ||
344 | + firebaseEvent._eventName = "did_tap_market_badge" | ||
345 | + firebaseEvent.setParameter = ("screen", "Loyalty History") | ||
346 | + SwiftEventBus.post("firebase", sender: firebaseEvent) | ||
347 | + | ||
348 | + swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "MarketBanner")) | ||
349 | + | ||
350 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | ||
351 | + let vc = storyboard.instantiateViewController(withIdentifier: "MarketLoyaltyAnalysisViewController") as! SwiftWarplyFramework.MarketLoyaltyAnalysisViewController | ||
352 | + self.navigationController?.pushViewController(vc, animated: true) | ||
353 | + } | ||
354 | + } | ||
29 | } | 355 | } | ... | ... |
This diff could not be displayed because it is too large.
... | @@ -122,6 +122,16 @@ import SwiftEventBus | ... | @@ -122,6 +122,16 @@ import SwiftEventBus |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | + SwiftEventBus.onBackgroundThread(self, name: "vouchers_service_unavailable") { result in | ||
126 | + | ||
127 | + DispatchQueue.main.async { | ||
128 | + print("=== vouchers_service_unavailable event ===") | ||
129 | + | ||
130 | + self.showVouchersFailureDialog() | ||
131 | + | ||
132 | + } | ||
133 | + } | ||
134 | + | ||
125 | // TODO: DELETE ===> | 135 | // TODO: DELETE ===> |
126 | // let coupon = swiftApi.ActiveDFYCouponModel() | 136 | // let coupon = swiftApi.ActiveDFYCouponModel() |
127 | // coupon._value = "12" | 137 | // coupon._value = "12" |
... | @@ -149,7 +159,7 @@ import SwiftEventBus | ... | @@ -149,7 +159,7 @@ import SwiftEventBus |
149 | // TODO: Uncomment when UnifiedCoupons will be shown again | 159 | // TODO: Uncomment when UnifiedCoupons will be shown again |
150 | // getCouponsSetsDealsRequest() | 160 | // getCouponsSetsDealsRequest() |
151 | 161 | ||
152 | - setBackButton() | 162 | + setBackButton("ic_close_3") |
153 | setNavigationTitle("My Rewards") | 163 | setNavigationTitle("My Rewards") |
154 | 164 | ||
155 | tableView.delegate = self | 165 | tableView.delegate = self |
... | @@ -606,6 +616,28 @@ import SwiftEventBus | ... | @@ -606,6 +616,28 @@ import SwiftEventBus |
606 | self.present(alert, animated: true, completion: nil) | 616 | self.present(alert, animated: true, completion: nil) |
607 | } | 617 | } |
608 | 618 | ||
619 | + func showVouchersFailureDialog() -> Void { | ||
620 | + | ||
621 | + let alert = UIAlertController(title: "Προσπάθησε ξανά αργότερα", message: "Προσωρινά μη διαθέσιμη πληροφορία.\nΠαρακαλούμε δοκίμασε ξανά σε λίγο.", preferredStyle: .alert) | ||
622 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
623 | + switch action.style{ | ||
624 | + case .default: | ||
625 | +// self.handleSpinnerAndEmptyView() | ||
626 | +// self.tableView.reloadData() | ||
627 | + self.navigationController?.popViewController(animated: true) | ||
628 | + self.dismiss(animated: true, completion: {}) | ||
629 | + | ||
630 | + case .cancel: | ||
631 | + print("cancel") | ||
632 | + | ||
633 | + case .destructive: | ||
634 | + print("destructive") | ||
635 | + | ||
636 | + } | ||
637 | + })) | ||
638 | + self.present(alert, animated: true, completion: nil) | ||
639 | + } | ||
640 | + | ||
609 | func startTimer() { | 641 | func startTimer() { |
610 | print("========= MyRewards Timer Started! =========") | 642 | print("========= MyRewards Timer Started! =========") |
611 | 643 | ||
... | @@ -720,15 +752,24 @@ import SwiftEventBus | ... | @@ -720,15 +752,24 @@ import SwiftEventBus |
720 | } | 752 | } |
721 | 753 | ||
722 | } else { | 754 | } else { |
723 | - self.emptyView.isHidden = true | ||
724 | - self.emptyViewHeight.constant = 0 | ||
725 | - | ||
726 | self.showSpinner = false | 755 | self.showSpinner = false |
727 | 756 | ||
728 | if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) { | 757 | if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) { |
729 | self.showActiveCouponsBanners = false | 758 | self.showActiveCouponsBanners = false |
730 | 759 | ||
760 | + if (swiftApi().getShowVouchersBanner() == "false") { | ||
761 | + self.emptyView.isHidden = false | ||
762 | + self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | ||
763 | + | ||
731 | } else { | 764 | } else { |
765 | + self.emptyView.isHidden = true | ||
766 | + self.emptyViewHeight.constant = 0 | ||
767 | + } | ||
768 | + | ||
769 | + } else { | ||
770 | + self.emptyView.isHidden = true | ||
771 | + self.emptyViewHeight.constant = 0 | ||
772 | + | ||
732 | self.showActiveCouponsBanners = true | 773 | self.showActiveCouponsBanners = true |
733 | } | 774 | } |
734 | } | 775 | } |
... | @@ -787,8 +828,9 @@ import SwiftEventBus | ... | @@ -787,8 +828,9 @@ import SwiftEventBus |
787 | 828 | ||
788 | swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyHistoryBadge")) | 829 | swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyHistoryBadge")) |
789 | 830 | ||
790 | - // TODO: Open new HistoryVC | 831 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
791 | - | 832 | + let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyHistoryViewController") as! SwiftWarplyFramework.LoyaltyHistoryViewController |
833 | + self.navigationController?.pushViewController(vc, animated: true) | ||
792 | } | 834 | } |
793 | 835 | ||
794 | @IBAction func dfyEarnButtonAction(_ sender: Any) { | 836 | @IBAction func dfyEarnButtonAction(_ sender: Any) { | ... | ... |
-
Please register or login to post a comment