Showing
5 changed files
with
38 additions
and
1 deletions
No preview for this file type
... | @@ -44,6 +44,7 @@ import AVFoundation | ... | @@ -44,6 +44,7 @@ import AVFoundation |
44 | var barcodeVisible: Bool = false; | 44 | var barcodeVisible: Bool = false; |
45 | 45 | ||
46 | public var coupon: swiftApi.CouponItemModel? | 46 | public var coupon: swiftApi.CouponItemModel? |
47 | + public var isFromWallet: Bool? = false | ||
47 | 48 | ||
48 | public override func viewDidLoad() { | 49 | public override func viewDidLoad() { |
49 | super.viewDidLoad() | 50 | super.viewDidLoad() |
... | @@ -235,6 +236,7 @@ import AVFoundation | ... | @@ -235,6 +236,7 @@ import AVFoundation |
235 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 236 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
236 | let vc = storyboard.instantiateViewController(withIdentifier: "ShareViewController") as! SwiftWarplyFramework.ShareViewController | 237 | let vc = storyboard.instantiateViewController(withIdentifier: "ShareViewController") as! SwiftWarplyFramework.ShareViewController |
237 | vc.coupon = self.coupon | 238 | vc.coupon = self.coupon |
239 | + vc.isFromWallet = self.isFromWallet | ||
238 | self.navigationController?.pushViewController(vc, animated: true) | 240 | self.navigationController?.pushViewController(vc, animated: true) |
239 | } | 241 | } |
240 | 242 | ... | ... |
... | @@ -26,6 +26,7 @@ import UIKit | ... | @@ -26,6 +26,7 @@ import UIKit |
26 | let uiscreen: CGRect = UIScreen.main.bounds | 26 | let uiscreen: CGRect = UIScreen.main.bounds |
27 | 27 | ||
28 | public var coupon: swiftApi.CouponItemModel? | 28 | public var coupon: swiftApi.CouponItemModel? |
29 | + public var isFromWallet: Bool? = false | ||
29 | var selectedNumber: String = "" | 30 | var selectedNumber: String = "" |
30 | var numbersList: Array<String> = [] | 31 | var numbersList: Array<String> = [] |
31 | 32 | ||
... | @@ -164,6 +165,29 @@ import UIKit | ... | @@ -164,6 +165,29 @@ import UIKit |
164 | self.present(alert, animated: true, completion: nil) | 165 | self.present(alert, animated: true, completion: nil) |
165 | } | 166 | } |
166 | 167 | ||
168 | + func showSuccessDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
169 | + | ||
170 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
171 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
172 | + switch action.style{ | ||
173 | + case .default: | ||
174 | + if (self.isFromWallet == true) { | ||
175 | + self.popBack(3) | ||
176 | + } else { | ||
177 | + print("default") | ||
178 | + } | ||
179 | + | ||
180 | + case .cancel: | ||
181 | + print("cancel") | ||
182 | + | ||
183 | + case .destructive: | ||
184 | + print("destructive") | ||
185 | + | ||
186 | + } | ||
187 | + })) | ||
188 | + self.present(alert, animated: true, completion: nil) | ||
189 | + } | ||
190 | + | ||
167 | // MARK: - API Calls | 191 | // MARK: - API Calls |
168 | func getProfileRequest() { | 192 | func getProfileRequest() { |
169 | swiftApi().getProfileAsync(getProfileCallback) | 193 | swiftApi().getProfileAsync(getProfileCallback) |
... | @@ -189,7 +213,6 @@ import UIKit | ... | @@ -189,7 +213,6 @@ import UIKit |
189 | if (response != nil) { | 213 | if (response != nil) { |
190 | DispatchQueue.main.async { | 214 | DispatchQueue.main.async { |
191 | if (response?.getStatus == 1) { | 215 | if (response?.getStatus == 1) { |
192 | - self.showDialog("Συγχαρητήρια!","Μόλις έκανες δώρο ένα κουπόνι!") | ||
193 | 216 | ||
194 | swiftApi().getCouponsAsync(getCouponsCallback) | 217 | swiftApi().getCouponsAsync(getCouponsCallback) |
195 | 218 | ||
... | @@ -197,6 +220,7 @@ import UIKit | ... | @@ -197,6 +220,7 @@ import UIKit |
197 | if (couponsData != nil) { | 220 | if (couponsData != nil) { |
198 | 221 | ||
199 | DispatchQueue.main.async { | 222 | DispatchQueue.main.async { |
223 | + self.showSuccessDialog("Συγχαρητήρια!","Μόλις έκανες δώρο ένα κουπόνι!") | ||
200 | } | 224 | } |
201 | } else { | 225 | } else { |
202 | } | 226 | } | ... | ... |
... | @@ -63,6 +63,16 @@ extension UIViewController { | ... | @@ -63,6 +63,16 @@ extension UIViewController { |
63 | self.navigationItem.titleView = titleLabel | 63 | self.navigationItem.titleView = titleLabel |
64 | 64 | ||
65 | } | 65 | } |
66 | + | ||
67 | + // pop back n viewcontroller | ||
68 | + func popBack(_ nb: Int) { | ||
69 | + if let viewControllers: [UIViewController] = self.navigationController?.viewControllers { | ||
70 | + guard viewControllers.count < nb else { | ||
71 | + self.navigationController?.popToViewController(viewControllers[viewControllers.count - nb], animated: true) | ||
72 | + return | ||
73 | + } | ||
74 | + } | ||
75 | + } | ||
66 | } | 76 | } |
67 | 77 | ||
68 | extension String { | 78 | extension String { | ... | ... |
... | @@ -412,6 +412,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -412,6 +412,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
412 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 412 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
413 | let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController | 413 | let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController |
414 | vc.coupon = coupons[indexPath.row] | 414 | vc.coupon = coupons[indexPath.row] |
415 | + vc.isFromWallet = true | ||
415 | self.navigationController?.pushViewController(vc, animated: true) | 416 | self.navigationController?.pushViewController(vc, animated: true) |
416 | 417 | ||
417 | } | 418 | } | ... | ... |
-
Please register or login to post a comment