Manos Chorianopoulos

add spinners

...@@ -31,6 +31,7 @@ import SwiftEventBus ...@@ -31,6 +31,7 @@ import SwiftEventBus
31 31
32 let uiscreen: CGRect = UIScreen.main.bounds 32 let uiscreen: CGRect = UIScreen.main.bounds
33 33
34 + let spinner = SpinnerViewController()
34 35
35 public override func viewDidLoad() { 36 public override func viewDidLoad() {
36 super.viewDidLoad() 37 super.viewDidLoad()
...@@ -122,6 +123,26 @@ import SwiftEventBus ...@@ -122,6 +123,26 @@ import SwiftEventBus
122 123
123 124
124 // MARK: - Functions 125 // MARK: - Functions
126 + func showSpinner() {
127 + // add the spinner view controller
128 + // addChild(spinner)
129 + // spinner.view.frame = view.frame
130 + // view.addSubview(spinner.view)
131 + // spinner.didMove(toParent: self)
132 +
133 + addChild(spinner)
134 + spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
135 + self.view.addSubview(spinner.view)
136 + spinner.didMove(toParent: self)
137 + }
138 +
139 + func hideSpinner() {
140 + // remove the spinner view controller
141 + spinner.willMove(toParent: nil)
142 + spinner.view.removeFromSuperview()
143 + spinner.removeFromParent()
144 + }
145 +
125 func toggleTerms() { 146 func toggleTerms() {
126 if (termsVisible) { 147 if (termsVisible) {
127 termsTextView.isHidden = false 148 termsTextView.isHidden = false
...@@ -269,9 +290,11 @@ import SwiftEventBus ...@@ -269,9 +290,11 @@ import SwiftEventBus
269 } 290 }
270 291
271 func submitOrderRequest() { 292 func submitOrderRequest() {
293 + self.showSpinner()
272 swiftApi().submitOrderAsync(campaign_session_uuid: "", user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), 294 swiftApi().submitOrderAsync(campaign_session_uuid: "", user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""),
273 OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""), 295 OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
274 submitOrderCallback, failureCallback: {errorCode in 296 submitOrderCallback, failureCallback: {errorCode in
297 + self.hideSpinner()
275 let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() 298 let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
276 firebaseEvent._eventName = "loyalty_offer_activated" 299 firebaseEvent._eventName = "loyalty_offer_activated"
277 firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) 300 firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
...@@ -284,6 +307,7 @@ import SwiftEventBus ...@@ -284,6 +307,7 @@ import SwiftEventBus
284 } 307 }
285 308
286 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void { 309 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
310 + self.hideSpinner()
287 if (response != nil) { 311 if (response != nil) {
288 DispatchQueue.main.async { 312 DispatchQueue.main.async {
289 if (response?.getStatus == 1) { 313 if (response?.getStatus == 1) {
......
...@@ -32,6 +32,8 @@ import SwiftEventBus ...@@ -32,6 +32,8 @@ import SwiftEventBus
32 var selectedNumber: String = "" 32 var selectedNumber: String = ""
33 var numbersList: Array<String> = [] 33 var numbersList: Array<String> = []
34 34
35 + let spinner = SpinnerViewController()
36 +
35 public override func viewDidLoad() { 37 public override func viewDidLoad() {
36 super.viewDidLoad() 38 super.viewDidLoad()
37 39
...@@ -154,6 +156,26 @@ import SwiftEventBus ...@@ -154,6 +156,26 @@ import SwiftEventBus
154 } 156 }
155 157
156 // MARK: - Functions 158 // MARK: - Functions
159 + func showSpinner() {
160 + // add the spinner view controller
161 + // addChild(spinner)
162 + // spinner.view.frame = view.frame
163 + // view.addSubview(spinner.view)
164 + // spinner.didMove(toParent: self)
165 +
166 + addChild(spinner)
167 + spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
168 + self.view.addSubview(spinner.view)
169 + spinner.didMove(toParent: self)
170 + }
171 +
172 + func hideSpinner() {
173 + // remove the spinner view controller
174 + spinner.willMove(toParent: nil)
175 + spinner.view.removeFromSuperview()
176 + spinner.removeFromParent()
177 + }
178 +
157 func showSendDialog() -> Void { 179 func showSendDialog() -> Void {
158 180
159 let alert = UIAlertController(title: "Δώρισέ το", message: "Είσαι σίγουρος /-ή ότι θέλεις να κάνεις δώρο το κουπόνι σου;", preferredStyle: .alert) 181 let alert = UIAlertController(title: "Δώρισέ το", message: "Είσαι σίγουρος /-ή ότι θέλεις να κάνεις δώρο το κουπόνι σου;", preferredStyle: .alert)
...@@ -274,12 +296,15 @@ import SwiftEventBus ...@@ -274,12 +296,15 @@ import SwiftEventBus
274 } 296 }
275 297
276 func cosmoteCouponSharingRequest() { 298 func cosmoteCouponSharingRequest() {
299 + self.showSpinner()
277 swiftApi().cosmoteCouponSharingAsync(coupon: coupon?.coupon ?? "", sender: selectedNumber, receiver: numberTextField.text ?? "", couponSharingCallback, failureCallback: {errorCode in 300 swiftApi().cosmoteCouponSharingAsync(coupon: coupon?.coupon ?? "", sender: selectedNumber, receiver: numberTextField.text ?? "", couponSharingCallback, failureCallback: {errorCode in
301 + self.hideSpinner()
278 self.showDialog("Αποτυχία","Κάτι πήγε στραβά") 302 self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
279 }) 303 })
280 } 304 }
281 305
282 func couponSharingCallback (_ response: swiftApi.GenericResponseModel?) -> Void { 306 func couponSharingCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
307 + self.hideSpinner()
283 if (response != nil) { 308 if (response != nil) {
284 DispatchQueue.main.async { 309 DispatchQueue.main.async {
285 if (response?.getStatus == 1) { 310 if (response?.getStatus == 1) {
......
...@@ -38,6 +38,8 @@ import SwiftEventBus ...@@ -38,6 +38,8 @@ import SwiftEventBus
38 38
39 var moreVisible: Bool = false; 39 var moreVisible: Bool = false;
40 40
41 + let spinner = SpinnerViewController()
42 +
41 public override func viewDidLoad() { 43 public override func viewDidLoad() {
42 44
43 super.viewDidLoad() 45 super.viewDidLoad()
...@@ -139,6 +141,26 @@ import SwiftEventBus ...@@ -139,6 +141,26 @@ import SwiftEventBus
139 } 141 }
140 142
141 // MARK: - Functions 143 // MARK: - Functions
144 + func showSpinner() {
145 + // add the spinner view controller
146 + // addChild(spinner)
147 + // spinner.view.frame = view.frame
148 + // view.addSubview(spinner.view)
149 + // spinner.didMove(toParent: self)
150 +
151 + addChild(spinner)
152 + spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
153 + self.view.addSubview(spinner.view)
154 + spinner.didMove(toParent: self)
155 + }
156 +
157 + func hideSpinner() {
158 + // remove the spinner view controller
159 + spinner.willMove(toParent: nil)
160 + spinner.view.removeFromSuperview()
161 + spinner.removeFromParent()
162 + }
163 +
142 func toggleMore() { 164 func toggleMore() {
143 if (moreVisible) { 165 if (moreVisible) {
144 moreTextView.isHidden = false 166 moreTextView.isHidden = false
...@@ -226,9 +248,11 @@ import SwiftEventBus ...@@ -226,9 +248,11 @@ import SwiftEventBus
226 } 248 }
227 249
228 func submitOrderRequest() { 250 func submitOrderRequest() {
251 + showSpinner()
229 swiftApi().submitOrderAsync(campaign_session_uuid: (campaign?.session_uuid ?? ""), user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), 252 swiftApi().submitOrderAsync(campaign_session_uuid: (campaign?.session_uuid ?? ""), user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""),
230 OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""), 253 OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
231 submitOrderCallback, failureCallback: {errorCode in 254 submitOrderCallback, failureCallback: {errorCode in
255 + self.hideSpinner()
232 let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() 256 let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
233 firebaseEvent._eventName = "loyalty_offer_activated" 257 firebaseEvent._eventName = "loyalty_offer_activated"
234 firebaseEvent.setParameter = ("name", (self.ccms?._title ?? "")) 258 firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
...@@ -241,6 +265,7 @@ import SwiftEventBus ...@@ -241,6 +265,7 @@ import SwiftEventBus
241 } 265 }
242 266
243 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void { 267 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
268 + self.hideSpinner()
244 if (response != nil) { 269 if (response != nil) {
245 DispatchQueue.main.async { 270 DispatchQueue.main.async {
246 if (response?.getStatus == 1) { 271 if (response?.getStatus == 1) {
......
...@@ -27,6 +27,8 @@ import SwiftEventBus ...@@ -27,6 +27,8 @@ import SwiftEventBus
27 public var coupon: swiftApi.UnifiedCouponModel? 27 public var coupon: swiftApi.UnifiedCouponModel?
28 public var isFromWallet: Bool? = false 28 public var isFromWallet: Bool? = false
29 29
30 + let spinner = SpinnerViewController()
31 +
30 public override func viewDidLoad() { 32 public override func viewDidLoad() {
31 super.viewDidLoad() 33 super.viewDidLoad()
32 34
...@@ -57,6 +59,26 @@ import SwiftEventBus ...@@ -57,6 +59,26 @@ import SwiftEventBus
57 59
58 60
59 // MARK: - Functions 61 // MARK: - Functions
62 + func showSpinner() {
63 + // add the spinner view controller
64 + // addChild(spinner)
65 + // spinner.view.frame = view.frame
66 + // view.addSubview(spinner.view)
67 + // spinner.didMove(toParent: self)
68 +
69 + addChild(spinner)
70 + spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
71 + self.view.addSubview(spinner.view)
72 + spinner.didMove(toParent: self)
73 + }
74 +
75 + func hideSpinner() {
76 + // remove the spinner view controller
77 + spinner.willMove(toParent: nil)
78 + spinner.view.removeFromSuperview()
79 + spinner.removeFromParent()
80 + }
81 +
60 func showConfirmDialog() -> Void { 82 func showConfirmDialog() -> Void {
61 83
62 let alert = UIAlertController(title: "Ακύρωση Κουπονιού", message: "Είσαι σίγουρος ότι θέλεις να ακυρώσεις το κουπόνι σου;", preferredStyle: .alert) 84 let alert = UIAlertController(title: "Ακύρωση Κουπονιού", message: "Είσαι σίγουρος ότι θέλεις να ακυρώσεις το κουπόνι σου;", preferredStyle: .alert)
...@@ -116,6 +138,7 @@ import SwiftEventBus ...@@ -116,6 +138,7 @@ import SwiftEventBus
116 } 138 }
117 139
118 func cancelUnifiedCouponRequest () -> Void { 140 func cancelUnifiedCouponRequest () -> Void {
141 + self.showSpinner()
119 var tranIdFound = ""; 142 var tranIdFound = "";
120 for coupon in self.coupon?._coupons ?? [] { 143 for coupon in self.coupon?._coupons ?? [] {
121 if ((coupon.transaction_uuid != nil) && coupon.transaction_uuid != "") { 144 if ((coupon.transaction_uuid != nil) && coupon.transaction_uuid != "") {
...@@ -125,11 +148,16 @@ import SwiftEventBus ...@@ -125,11 +148,16 @@ import SwiftEventBus
125 } 148 }
126 149
127 if (tranIdFound != "") { 150 if (tranIdFound != "") {
128 - swiftApi().cancelUnifiedCouponAsync(transactionId: tranIdFound, self.cancelUnifiedCouponCallback, failureCallback: { errorCode in }) 151 + swiftApi().cancelUnifiedCouponAsync(transactionId: tranIdFound, self.cancelUnifiedCouponCallback, failureCallback: { errorCode in
152 + self.hideSpinner()
153 + })
154 + } else {
155 + self.hideSpinner()
129 } 156 }
130 } 157 }
131 158
132 func cancelUnifiedCouponCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void { 159 func cancelUnifiedCouponCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
160 + self.hideSpinner()
133 if (responseData != nil) { 161 if (responseData != nil) {
134 DispatchQueue.main.async { 162 DispatchQueue.main.async {
135 if (responseData?.getStatus == 1) { 163 if (responseData?.getStatus == 1) {
......
...@@ -29,6 +29,8 @@ import SwiftEventBus ...@@ -29,6 +29,8 @@ import SwiftEventBus
29 // Track the selection state 29 // Track the selection state
30 var isSelectAllActive: Bool = false 30 var isSelectAllActive: Bool = false
31 31
32 + let spinner = SpinnerViewController()
33 +
32 34
33 public override func viewDidLoad() { 35 public override func viewDidLoad() {
34 super.viewDidLoad() 36 super.viewDidLoad()
...@@ -141,6 +143,26 @@ import SwiftEventBus ...@@ -141,6 +143,26 @@ import SwiftEventBus
141 } 143 }
142 144
143 // MARK: - Functions 145 // MARK: - Functions
146 + func showSpinner() {
147 + // add the spinner view controller
148 + // addChild(spinner)
149 + // spinner.view.frame = view.frame
150 + // view.addSubview(spinner.view)
151 + // spinner.didMove(toParent: self)
152 +
153 + addChild(spinner)
154 + spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
155 + self.view.addSubview(spinner.view)
156 + spinner.didMove(toParent: self)
157 + }
158 +
159 + func hideSpinner() {
160 + // remove the spinner view controller
161 + spinner.willMove(toParent: nil)
162 + spinner.view.removeFromSuperview()
163 + spinner.removeFromParent()
164 + }
165 +
144 // Button action for "select all" 166 // Button action for "select all"
145 @objc func selectAllTapped() { 167 @objc func selectAllTapped() {
146 // Toggle the selection state 168 // Toggle the selection state
...@@ -267,9 +289,10 @@ import SwiftEventBus ...@@ -267,9 +289,10 @@ import SwiftEventBus
267 @IBAction func submitButtonAction(_ sender: Any) { 289 @IBAction func submitButtonAction(_ sender: Any) {
268 // let smCouponsString = self.smCouponsSelected.map { $0.coupon ?? "" }.joined(separator: ",") 290 // let smCouponsString = self.smCouponsSelected.map { $0.coupon ?? "" }.joined(separator: ",")
269 // swiftApi().logTrackersEvent("click", ("UnifySMCoupons:" + (smCouponsString))) 291 // swiftApi().logTrackersEvent("click", ("UnifySMCoupons:" + (smCouponsString)))
270 - 292 + self.showSpinner()
271 let smCouponCodes = self.smCouponsSelected.map { $0.coupon ?? "" } 293 let smCouponCodes = self.smCouponsSelected.map { $0.coupon ?? "" }
272 swiftApi().createUnifiedCouponAsync(couponCodes: smCouponCodes) { responseData in 294 swiftApi().createUnifiedCouponAsync(couponCodes: smCouponCodes) { responseData in
295 + self.hideSpinner()
273 if (responseData != nil) { 296 if (responseData != nil) {
274 DispatchQueue.main.async { 297 DispatchQueue.main.async {
275 if (responseData?.getStatus == 1) { 298 if (responseData?.getStatus == 1) {
...@@ -285,6 +308,7 @@ import SwiftEventBus ...@@ -285,6 +308,7 @@ import SwiftEventBus
285 } 308 }
286 } 309 }
287 } failureCallback: { errorCode in 310 } failureCallback: { errorCode in
311 + self.hideSpinner()
288 self.showFailureDialog() 312 self.showFailureDialog()
289 } 313 }
290 314
......