Manos Chorianopoulos

Added no vouchers UI in myRewards

...@@ -93,6 +93,8 @@ import SwiftEventBus ...@@ -93,6 +93,8 @@ import SwiftEventBus
93 self.coupons = swiftApi().getCouponList() 93 self.coupons = swiftApi().getCouponList()
94 self.totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100) 94 self.totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
95 self.loyaltyBadge = swiftApi().getLoyaltyBadge() 95 self.loyaltyBadge = swiftApi().getLoyaltyBadge()
96 +
97 + self.handleSpinnerAndEmptyView()
96 self.tableView.reloadData() 98 self.tableView.reloadData()
97 } 99 }
98 } 100 }
...@@ -753,7 +755,7 @@ import SwiftEventBus ...@@ -753,7 +755,7 @@ import SwiftEventBus
753 if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) { 755 if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) {
754 self.showActiveCouponsBanners = false 756 self.showActiveCouponsBanners = false
755 757
756 - if (swiftApi().getShowVouchersBanner() == "false") { 758 + if (swiftApi().getShowVouchersBanner() == "null") {
757 self.emptyView.isHidden = false 759 self.emptyView.isHidden = false
758 self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height 760 self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
759 761
...@@ -1058,7 +1060,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -1058,7 +1060,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
1058 return 0 1060 return 0
1059 } 1061 }
1060 } else if (section == 1) { 1062 } else if (section == 1) {
1061 - if (swiftApi().getShowVouchersBanner() == "true") { 1063 + if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
1062 return 1 1064 return 1
1063 } else { 1065 } else {
1064 return 0 1066 return 0
...@@ -1112,7 +1114,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -1112,7 +1114,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
1112 return 0.0 1114 return 0.0
1113 } 1115 }
1114 } else if (indexPath.section == 1) { 1116 } else if (indexPath.section == 1) {
1115 - if (swiftApi().getShowVouchersBanner() == "true") { 1117 + if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
1116 return UITableView.automaticDimension 1118 return UITableView.automaticDimension
1117 } else { 1119 } else {
1118 return 0.0 1120 return 0.0
...@@ -1208,7 +1210,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -1208,7 +1210,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
1208 return nil 1210 return nil
1209 } 1211 }
1210 } else if (section == 1) { 1212 } else if (section == 1) {
1211 -// if (swiftApi().getShowVouchersBanner() == "true") { 1213 +// if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
1212 // let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 70)) 1214 // let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 70))
1213 // view.backgroundColor = .clear 1215 // view.backgroundColor = .clear
1214 1216
...@@ -1268,7 +1270,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -1268,7 +1270,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
1268 return 0.0 1270 return 0.0
1269 } 1271 }
1270 } else if (section == 1) { 1272 } else if (section == 1) {
1271 -// if (swiftApi().getShowVouchersBanner() == "true") { 1273 +// if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
1272 // return 70.0 1274 // return 70.0
1273 // } else { 1275 // } else {
1274 return 0.0 1276 return 0.0
...@@ -1322,7 +1324,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -1322,7 +1324,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
1322 1324
1323 } else if (indexPath.section == 1) { 1325 } else if (indexPath.section == 1) {
1324 let cell = tableView.dequeueReusableCell(withIdentifier: "WalletVouchersBannerTableViewCellId", for: indexPath) as! WalletVouchersBannerTableViewCell 1326 let cell = tableView.dequeueReusableCell(withIdentifier: "WalletVouchersBannerTableViewCellId", for: indexPath) as! WalletVouchersBannerTableViewCell
1325 - cell.configureCell(showSeparator: self.showActiveCouponsBanners) 1327 + cell.configureCell(showSeparator: self.showActiveCouponsBanners, active: swiftApi().getShowVouchersBanner() == "true")
1326 return cell 1328 return cell
1327 } else { 1329 } else {
1328 let cell = tableView.dequeueReusableCell(withIdentifier: "WalletSpinnerTableViewCellId", for: indexPath) as! WalletSpinnerTableViewCell 1330 let cell = tableView.dequeueReusableCell(withIdentifier: "WalletSpinnerTableViewCellId", for: indexPath) as! WalletSpinnerTableViewCell
......
...@@ -15,6 +15,7 @@ import UIKit ...@@ -15,6 +15,7 @@ import UIKit
15 @IBOutlet weak var voucherBannerIconImage: UIImageView! 15 @IBOutlet weak var voucherBannerIconImage: UIImageView!
16 @IBOutlet weak var voucherBannerLabel: UILabel! 16 @IBOutlet weak var voucherBannerLabel: UILabel!
17 @IBOutlet weak var voucherBannerArrowImage: UIImageView! 17 @IBOutlet weak var voucherBannerArrowImage: UIImageView!
18 + @IBOutlet weak var voucherCountView: UIView!
18 19
19 public override func awakeFromNib() { 20 public override func awakeFromNib() {
20 super.awakeFromNib() 21 super.awakeFromNib()
...@@ -35,7 +36,10 @@ import UIKit ...@@ -35,7 +36,10 @@ import UIKit
35 voucherBannerIconImage.image = UIImage(named: "wallet_voucher", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 36 voucherBannerIconImage.image = UIImage(named: "wallet_voucher", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
36 voucherBannerArrowImage.image = UIImage(named: "arrow_right_black", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 37 voucherBannerArrowImage.image = UIImage(named: "arrow_right_black", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
37 38
38 - voucherBannerLabel.text = "Ενημερώσου για το υπόλοιπο επιδότησης" 39 +// voucherBannerLabel.text = "Ενημερώσου για το υπόλοιπο επιδότησης"
40 +
41 + voucherCountView.layer.cornerRadius = 4.0
42 + voucherCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
39 } 43 }
40 44
41 public override func setSelected(_ selected: Bool, animated: Bool) { 45 public override func setSelected(_ selected: Bool, animated: Bool) {
...@@ -44,7 +48,7 @@ import UIKit ...@@ -44,7 +48,7 @@ import UIKit
44 // Configure the view for the selected state 48 // Configure the view for the selected state
45 } 49 }
46 50
47 - func configureCell(showSeparator: Bool) { 51 + func configureCell(showSeparator: Bool, active: Bool) {
48 if (showSeparator == true) { 52 if (showSeparator == true) {
49 separatorView.isHidden = false 53 separatorView.isHidden = false
50 separatorTopSpace.constant = 25 54 separatorTopSpace.constant = 25
...@@ -53,6 +57,25 @@ import UIKit ...@@ -53,6 +57,25 @@ import UIKit
53 separatorView.isHidden = true 57 separatorView.isHidden = true
54 separatorTopSpace.constant = 0 58 separatorTopSpace.constant = 0
55 } 59 }
60 +
61 + if (active == true) {
62 + voucherBannerView.backgroundColor = .white
63 + voucherBannerIconImage.image = voucherBannerIconImage.image?.withRenderingMode(.alwaysTemplate)
64 + voucherBannerIconImage.tintColor = UIColor(red: 0.00, green: 0.65, blue: 0.89, alpha: 1.00)
65 + voucherBannerLabel.text = "Ενημερώσου για το υπόλοιπο επιδότησης"
66 + voucherBannerLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
67 + voucherBannerLabel.frame.size.width = voucherBannerLabel.intrinsicContentSize.width
68 + voucherCountView.isHidden = true
69 +
70 + } else {
71 + voucherBannerView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
72 + voucherBannerIconImage.image = voucherBannerIconImage.image?.withRenderingMode(.alwaysTemplate)
73 + voucherBannerIconImage.tintColor = UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)
74 + voucherBannerLabel.text = "Διαθέσιμο υπόλοιπο"
75 + voucherBannerLabel.textColor = UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)
76 + voucherBannerLabel.frame.size.width = voucherBannerLabel.intrinsicContentSize.width
77 + voucherCountView.isHidden = false
78 + }
56 } 79 }
57 80
58 } 81 }
......
...@@ -183,11 +183,10 @@ public class swiftApi { ...@@ -183,11 +183,10 @@ public class swiftApi {
183 } 183 }
184 184
185 185
186 - public func setVouchersFetched(_ success: Bool) -> Void { 186 + public func setVouchersFetched(_ success: String) -> Void {
187 - if (success == true) { 187 + // Possible values "true", "false", "null"
188 - setShowVouchersBanner("true") 188 + if (success == "true" || success == "false" || success == "null") {
189 - } else { 189 + setShowVouchersBanner(success)
190 - setShowVouchersBanner("false")
191 } 190 }
192 191
193 SwiftEventBus.post("vouchers_fetched") 192 SwiftEventBus.post("vouchers_fetched")
......