Showing
2 changed files
with
62 additions
and
0 deletions
... | @@ -77,6 +77,10 @@ import SwiftEventBus | ... | @@ -77,6 +77,10 @@ import SwiftEventBus |
77 | 77 | ||
78 | var forYouExpanded: Bool = false; | 78 | var forYouExpanded: Bool = false; |
79 | 79 | ||
80 | + | ||
81 | + // TODO: Add SwiftEventBus.post("vouchers_banner_pressed") on Voucher Banner press | ||
82 | + | ||
83 | + | ||
80 | public override func viewDidLoad() { | 84 | public override func viewDidLoad() { |
81 | super.viewDidLoad() | 85 | super.viewDidLoad() |
82 | 86 | ||
... | @@ -103,6 +107,22 @@ import SwiftEventBus | ... | @@ -103,6 +107,22 @@ import SwiftEventBus |
103 | } | 107 | } |
104 | } | 108 | } |
105 | 109 | ||
110 | + SwiftEventBus.onBackgroundThread(self, name: "vouchers_fetched") { result in | ||
111 | + | ||
112 | + DispatchQueue.main.async { | ||
113 | + print("=== vouchers_fetched event ===") | ||
114 | + | ||
115 | + // TODO: hide Spinner | ||
116 | + | ||
117 | + if (swiftApi().getShowVouchersBanner() == "true") { | ||
118 | + // TODO: show Vouchers Banner | ||
119 | + } else { | ||
120 | + // TODO: hide Vouchers Banner | ||
121 | + } | ||
122 | + | ||
123 | + } | ||
124 | + } | ||
125 | + | ||
106 | // TODO: DELETE ===> | 126 | // TODO: DELETE ===> |
107 | // let coupon = swiftApi.ActiveDFYCouponModel() | 127 | // let coupon = swiftApi.ActiveDFYCouponModel() |
108 | // coupon._value = "12" | 128 | // coupon._value = "12" |
... | @@ -462,6 +482,16 @@ import SwiftEventBus | ... | @@ -462,6 +482,16 @@ import SwiftEventBus |
462 | // TODO: DELETE if emptyView is needed again | 482 | // TODO: DELETE if emptyView is needed again |
463 | emptyView.isHidden = true | 483 | emptyView.isHidden = true |
464 | emptyViewHeight.constant = 0 | 484 | emptyViewHeight.constant = 0 |
485 | + | ||
486 | + if (swiftApi().getShowVouchersBanner() == "") { | ||
487 | + // TODO: show Spinner | ||
488 | + // TODO: hide Vouchers Banner | ||
489 | + } else if (swiftApi().getShowVouchersBanner() == "true") { | ||
490 | + // TODO: show Vouchers Banner | ||
491 | + } else { | ||
492 | + // TODO: hide Vouchers Banner | ||
493 | + } | ||
494 | + | ||
465 | } | 495 | } |
466 | 496 | ||
467 | public override func viewWillAppear(_ animated: Bool) { | 497 | public override func viewWillAppear(_ animated: Bool) { |
... | @@ -530,6 +560,11 @@ import SwiftEventBus | ... | @@ -530,6 +560,11 @@ import SwiftEventBus |
530 | 560 | ||
531 | self.stopTimer() | 561 | self.stopTimer() |
532 | self.navigationController?.navigationBar.layer.shadowOpacity = 0.0 | 562 | self.navigationController?.navigationBar.layer.shadowOpacity = 0.0 |
563 | + | ||
564 | + if self.isMovingFromParent { | ||
565 | + // Clear ShowVouchersBanner state | ||
566 | + swiftApi().clearShowVouchersBanner(); | ||
567 | + } | ||
533 | } | 568 | } |
534 | 569 | ||
535 | public override func viewDidLayoutSubviews() { | 570 | public override func viewDidLayoutSubviews() { | ... | ... |
... | @@ -35,6 +35,7 @@ public struct GlobalVariables { | ... | @@ -35,6 +35,7 @@ public struct GlobalVariables { |
35 | static var merchantList: Array<swiftApi.MerchantModel> = [] | 35 | static var merchantList: Array<swiftApi.MerchantModel> = [] |
36 | static var trackingStepsEnabled: Bool = false | 36 | static var trackingStepsEnabled: Bool = false |
37 | static var carouselList: Array<swiftApi.CampaignItemModel> = [] | 37 | static var carouselList: Array<swiftApi.CampaignItemModel> = [] |
38 | + static var showVouchersBanner: String = "" // We use String in order to have 3 different states: "", "true", "false" | ||
38 | } | 39 | } |
39 | 40 | ||
40 | var timer: DispatchSourceTimer? | 41 | var timer: DispatchSourceTimer? |
... | @@ -167,6 +168,32 @@ public class swiftApi { | ... | @@ -167,6 +168,32 @@ public class swiftApi { |
167 | } | 168 | } |
168 | 169 | ||
169 | 170 | ||
171 | + public func setShowVouchersBanner(_ newValue: String) { | ||
172 | + GlobalVariables.showVouchersBanner = newValue | ||
173 | + } | ||
174 | + | ||
175 | + | ||
176 | + public func getShowVouchersBanner() -> String { | ||
177 | + return GlobalVariables.showVouchersBanner | ||
178 | + } | ||
179 | + | ||
180 | + | ||
181 | + public func clearShowVouchersBanner() -> Void { | ||
182 | + GlobalVariables.showVouchersBanner = "" | ||
183 | + } | ||
184 | + | ||
185 | + | ||
186 | + public func setVouchersFetched(_ success: Bool) -> Void { | ||
187 | + if (success == true) { | ||
188 | + setShowVouchersBanner("true") | ||
189 | + } else { | ||
190 | + setShowVouchersBanner("false") | ||
191 | + } | ||
192 | + | ||
193 | + SwiftEventBus.post("vouchers_fetched") | ||
194 | + } | ||
195 | + | ||
196 | + | ||
170 | public func startTrackingSteps(_ getStepsCallback: @escaping (_ steps: Int) -> Void) -> Void { | 197 | public func startTrackingSteps(_ getStepsCallback: @escaping (_ steps: Int) -> Void) -> Void { |
171 | 198 | ||
172 | if (GlobalVariables.trackingStepsEnabled == false) { | 199 | if (GlobalVariables.trackingStepsEnabled == false) { | ... | ... |
-
Please register or login to post a comment