Showing
5 changed files
with
106 additions
and
28 deletions
No preview for this file type
This diff is collapsed. Click to expand it.
... | @@ -8,10 +8,16 @@ | ... | @@ -8,10 +8,16 @@ |
8 | import UIKit | 8 | import UIKit |
9 | 9 | ||
10 | @objc public class WalletSpinnerTableViewCell: UITableViewCell { | 10 | @objc public class WalletSpinnerTableViewCell: UITableViewCell { |
11 | - | 11 | + @IBOutlet weak var spinner: UIActivityIndicatorView! |
12 | + | ||
12 | public override func awakeFromNib() { | 13 | public override func awakeFromNib() { |
13 | super.awakeFromNib() | 14 | super.awakeFromNib() |
14 | // Initialization code | 15 | // Initialization code |
16 | + | ||
17 | + spinner.color = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00) | ||
18 | + | ||
19 | + spinner.translatesAutoresizingMaskIntoConstraints = false | ||
20 | + spinner.startAnimating() | ||
15 | } | 21 | } |
16 | 22 | ||
17 | public override func setSelected(_ selected: Bool, animated: Bool) { | 23 | public override func setSelected(_ selected: Bool, animated: Bool) { |
... | @@ -19,5 +25,12 @@ import UIKit | ... | @@ -19,5 +25,12 @@ import UIKit |
19 | 25 | ||
20 | // Configure the view for the selected state | 26 | // Configure the view for the selected state |
21 | } | 27 | } |
22 | - | 28 | + |
29 | + // This is a fix for spinner stopping its animation when reusing cells | ||
30 | + public override func prepareForReuse() { | ||
31 | + super.prepareForReuse() | ||
32 | + if let spinner = self.spinner { | ||
33 | + spinner.startAnimating() | ||
34 | + } | ||
35 | + } | ||
23 | } | 36 | } | ... | ... |
... | @@ -78,6 +78,8 @@ import SwiftEventBus | ... | @@ -78,6 +78,8 @@ import SwiftEventBus |
78 | var unifiedCouponsDiscount:Float = 0.0 | 78 | var unifiedCouponsDiscount:Float = 0.0 |
79 | 79 | ||
80 | var forYouExpanded: Bool = false; | 80 | var forYouExpanded: Bool = false; |
81 | + var showSpinner: Bool = false; | ||
82 | + var showActiveCouponsBanners: Bool = false; | ||
81 | 83 | ||
82 | 84 | ||
83 | public override func viewDidLoad() { | 85 | public override func viewDidLoad() { |
... | @@ -100,8 +102,10 @@ import SwiftEventBus | ... | @@ -100,8 +102,10 @@ import SwiftEventBus |
100 | DispatchQueue.main.async { | 102 | DispatchQueue.main.async { |
101 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() | 103 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() |
102 | // TODO: Maybe add this | 104 | // TODO: Maybe add this |
103 | - self.matchOldSMCoupons() | 105 | + // TODO: Uncomment if discounts are shown again in wallet |
104 | - self.updateMarketBadge() | 106 | +// self.matchOldSMCoupons() |
107 | +// self.updateMarketBadge() | ||
108 | + self.handleSpinnerAndEmptyView() | ||
105 | self.tableView.reloadData() | 109 | self.tableView.reloadData() |
106 | } | 110 | } |
107 | } | 111 | } |
... | @@ -111,13 +115,9 @@ import SwiftEventBus | ... | @@ -111,13 +115,9 @@ import SwiftEventBus |
111 | DispatchQueue.main.async { | 115 | DispatchQueue.main.async { |
112 | print("=== vouchers_fetched event ===") | 116 | print("=== vouchers_fetched event ===") |
113 | 117 | ||
114 | - // TODO: hide Spinner | 118 | + self.handleSpinnerAndEmptyView() |
115 | - | 119 | +// self.showSpinner = false |
116 | - if (swiftApi().getShowVouchersBanner() == "true") { | 120 | + self.tableView.reloadData() |
117 | - // TODO: show Vouchers Banner | ||
118 | - } else { | ||
119 | - // TODO: hide Vouchers Banner | ||
120 | - } | ||
121 | 121 | ||
122 | } | 122 | } |
123 | } | 123 | } |
... | @@ -481,21 +481,15 @@ import SwiftEventBus | ... | @@ -481,21 +481,15 @@ import SwiftEventBus |
481 | emptyImage.image = UIImage(named: "ic_empty_wallet_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | 481 | emptyImage.image = UIImage(named: "ic_empty_wallet_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) |
482 | emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!" | 482 | emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!" |
483 | 483 | ||
484 | - matchOldSMCoupons() | 484 | + // TODO: Uncomment if discounts are shown again in wallet |
485 | - updateMarketBadge() | 485 | +// matchOldSMCoupons() |
486 | +// updateMarketBadge() | ||
486 | 487 | ||
487 | // TODO: DELETE if emptyView is needed again | 488 | // TODO: DELETE if emptyView is needed again |
488 | - emptyView.isHidden = true | 489 | +// emptyView.isHidden = true |
489 | - emptyViewHeight.constant = 0 | 490 | +// emptyViewHeight.constant = 0 |
490 | 491 | ||
491 | - if (swiftApi().getShowVouchersBanner() == "") { | 492 | + self.handleSpinnerAndEmptyView() |
492 | - // TODO: show Spinner | ||
493 | - // TODO: hide Vouchers Banner | ||
494 | - } else if (swiftApi().getShowVouchersBanner() == "true") { | ||
495 | - // TODO: show Vouchers Banner | ||
496 | - } else { | ||
497 | - // TODO: hide Vouchers Banner | ||
498 | - } | ||
499 | 493 | ||
500 | } | 494 | } |
501 | 495 | ||
... | @@ -554,7 +548,9 @@ import SwiftEventBus | ... | @@ -554,7 +548,9 @@ import SwiftEventBus |
554 | // TODO: Maybe add this | 548 | // TODO: Maybe add this |
555 | // self.matchOldSMCoupons() | 549 | // self.matchOldSMCoupons() |
556 | // <=== | 550 | // <=== |
557 | - self.updateMarketBadge() | 551 | + // TODO: Uncomment if discounts are shown again in wallet |
552 | +// self.updateMarketBadge() | ||
553 | + self.handleSpinnerAndEmptyView() | ||
558 | self.tableView.reloadData() | 554 | self.tableView.reloadData() |
559 | 555 | ||
560 | self.startTimer() | 556 | self.startTimer() |
... | @@ -705,6 +701,40 @@ import SwiftEventBus | ... | @@ -705,6 +701,40 @@ import SwiftEventBus |
705 | 701 | ||
706 | } | 702 | } |
707 | 703 | ||
704 | + func handleSpinnerAndEmptyView() { | ||
705 | + if (swiftApi().getShowVouchersBanner() == "") { | ||
706 | + self.showSpinner = true | ||
707 | + | ||
708 | + if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) { | ||
709 | + self.showSpinner = false | ||
710 | + self.showActiveCouponsBanners = false | ||
711 | + | ||
712 | + self.emptyView.isHidden = false | ||
713 | + self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | ||
714 | + | ||
715 | + } else { | ||
716 | + self.emptyView.isHidden = true | ||
717 | + self.emptyViewHeight.constant = 0 | ||
718 | + | ||
719 | + self.showActiveCouponsBanners = true | ||
720 | + } | ||
721 | + | ||
722 | + } else { | ||
723 | + self.emptyView.isHidden = true | ||
724 | + self.emptyViewHeight.constant = 0 | ||
725 | + | ||
726 | + self.showSpinner = false | ||
727 | + | ||
728 | + if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) { | ||
729 | + self.showActiveCouponsBanners = false | ||
730 | + | ||
731 | + } else { | ||
732 | + self.showActiveCouponsBanners = true | ||
733 | + } | ||
734 | + } | ||
735 | + } | ||
736 | + | ||
737 | + | ||
708 | // MARK: - API Functions | 738 | // MARK: - API Functions |
709 | func getCouponsSetsDealsRequest() { | 739 | func getCouponsSetsDealsRequest() { |
710 | swiftApi().getCouponSetsDealsAsync(getCouponsSetsDealsCallback, failureCallback: {errorCode in | 740 | swiftApi().getCouponSetsDealsAsync(getCouponsSetsDealsCallback, failureCallback: {errorCode in |
... | @@ -734,6 +764,7 @@ import SwiftEventBus | ... | @@ -734,6 +764,7 @@ import SwiftEventBus |
734 | DispatchQueue.main.async { | 764 | DispatchQueue.main.async { |
735 | self.matchOldSMCoupons() | 765 | self.matchOldSMCoupons() |
736 | self.updateMarketBadge() | 766 | self.updateMarketBadge() |
767 | + self.handleSpinnerAndEmptyView() | ||
737 | self.tableView.reloadData() | 768 | self.tableView.reloadData() |
738 | } | 769 | } |
739 | } else { | 770 | } else { |
... | @@ -957,7 +988,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -957,7 +988,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
957 | 988 | ||
958 | public func numberOfSections(in tableView: UITableView) -> Int { | 989 | public func numberOfSections(in tableView: UITableView) -> Int { |
959 | // return 4 | 990 | // return 4 |
960 | - return 2 | 991 | + return 3 |
961 | } | 992 | } |
962 | 993 | ||
963 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | 994 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
... | @@ -994,6 +1025,12 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -994,6 +1025,12 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
994 | } else { | 1025 | } else { |
995 | return 0 | 1026 | return 0 |
996 | } | 1027 | } |
1028 | + } else if (section == 2) { | ||
1029 | + if (self.showSpinner == true) { | ||
1030 | + return 1 | ||
1031 | + } else { | ||
1032 | + return 0 | ||
1033 | + } | ||
997 | } else { | 1034 | } else { |
998 | return 0 | 1035 | return 0 |
999 | } | 1036 | } |
... | @@ -1042,6 +1079,12 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -1042,6 +1079,12 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
1042 | } else { | 1079 | } else { |
1043 | return 0.0 | 1080 | return 0.0 |
1044 | } | 1081 | } |
1082 | + } else if (indexPath.section == 2) { | ||
1083 | + if (self.showSpinner == true) { | ||
1084 | + return UITableView.automaticDimension | ||
1085 | + } else { | ||
1086 | + return 0.0 | ||
1087 | + } | ||
1045 | } else { | 1088 | } else { |
1046 | return 0.0 | 1089 | return 0.0 |
1047 | } | 1090 | } |
... | @@ -1141,6 +1184,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -1141,6 +1184,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
1141 | // } else { | 1184 | // } else { |
1142 | return nil | 1185 | return nil |
1143 | // } | 1186 | // } |
1187 | + } else if (section == 2) { | ||
1188 | + return nil | ||
1144 | } else { | 1189 | } else { |
1145 | return nil | 1190 | return nil |
1146 | } | 1191 | } |
... | @@ -1187,6 +1232,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -1187,6 +1232,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
1187 | // } else { | 1232 | // } else { |
1188 | return 0.0 | 1233 | return 0.0 |
1189 | // } | 1234 | // } |
1235 | + } else if (section == 2) { | ||
1236 | + return 0.0 | ||
1190 | } else { | 1237 | } else { |
1191 | return 0.0 | 1238 | return 0.0 |
1192 | } | 1239 | } |
... | @@ -1232,12 +1279,15 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -1232,12 +1279,15 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
1232 | cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count) | 1279 | cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count) |
1233 | return cell | 1280 | return cell |
1234 | 1281 | ||
1235 | - } else { | 1282 | + } else if (indexPath.section == 1) { |
1236 | let cell = tableView.dequeueReusableCell(withIdentifier: "WalletVouchersBannerTableViewCellId", for: indexPath) as! WalletVouchersBannerTableViewCell | 1283 | let cell = tableView.dequeueReusableCell(withIdentifier: "WalletVouchersBannerTableViewCellId", for: indexPath) as! WalletVouchersBannerTableViewCell |
1237 | -// cell.configureCell(totalCouponValue: self.totalCouponValue, totalCouponDiscount: self.totalCouponDiscount, unifiedCouponsDiscount: self.unifiedCouponsDiscount, forYouExpanded: self.forYouExpanded) | 1284 | + cell.configureCell(showSeparator: self.showActiveCouponsBanners) |
1285 | + return cell | ||
1286 | + } else { | ||
1287 | + let cell = tableView.dequeueReusableCell(withIdentifier: "WalletSpinnerTableViewCellId", for: indexPath) as! WalletSpinnerTableViewCell | ||
1238 | return cell | 1288 | return cell |
1239 | } | 1289 | } |
1240 | - | 1290 | + |
1241 | } | 1291 | } |
1242 | 1292 | ||
1243 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 1293 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
... | @@ -1292,6 +1342,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -1292,6 +1342,8 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ |
1292 | 1342 | ||
1293 | SwiftEventBus.post("vouchers_banner_pressed") | 1343 | SwiftEventBus.post("vouchers_banner_pressed") |
1294 | 1344 | ||
1345 | + } else if (indexPath.section == 2) { | ||
1346 | + // Do nothing | ||
1295 | } else { | 1347 | } else { |
1296 | // Do nothing | 1348 | // Do nothing |
1297 | } | 1349 | } | ... | ... |
... | @@ -8,6 +8,8 @@ | ... | @@ -8,6 +8,8 @@ |
8 | import UIKit | 8 | import UIKit |
9 | 9 | ||
10 | @objc public class WalletVouchersBannerTableViewCell: UITableViewCell { | 10 | @objc public class WalletVouchersBannerTableViewCell: UITableViewCell { |
11 | + @IBOutlet weak var separatorView: UIView! | ||
12 | + @IBOutlet weak var separatorTopSpace: NSLayoutConstraint! | ||
11 | @IBOutlet weak var sectionTitleLabel: UILabel! | 13 | @IBOutlet weak var sectionTitleLabel: UILabel! |
12 | @IBOutlet weak var voucherBannerView: UIView! | 14 | @IBOutlet weak var voucherBannerView: UIView! |
13 | @IBOutlet weak var voucherBannerIconImage: UIImageView! | 15 | @IBOutlet weak var voucherBannerIconImage: UIImageView! |
... | @@ -41,5 +43,16 @@ import UIKit | ... | @@ -41,5 +43,16 @@ import UIKit |
41 | 43 | ||
42 | // Configure the view for the selected state | 44 | // Configure the view for the selected state |
43 | } | 45 | } |
46 | + | ||
47 | + func configureCell(showSeparator: Bool) { | ||
48 | + if (showSeparator == true) { | ||
49 | + separatorView.isHidden = false | ||
50 | + separatorTopSpace.constant = 25 | ||
51 | + | ||
52 | + } else { | ||
53 | + separatorView.isHidden = true | ||
54 | + separatorTopSpace.constant = 0 | ||
55 | + } | ||
56 | + } | ||
44 | 57 | ||
45 | } | 58 | } | ... | ... |
-
Please register or login to post a comment