Manos Chorianopoulos

Added no vouchers UI in myRewards

......@@ -93,6 +93,8 @@ import SwiftEventBus
self.coupons = swiftApi().getCouponList()
self.totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
self.loyaltyBadge = swiftApi().getLoyaltyBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
}
......@@ -753,7 +755,7 @@ import SwiftEventBus
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.coupons.count == 0) {
self.showActiveCouponsBanners = false
if (swiftApi().getShowVouchersBanner() == "false") {
if (swiftApi().getShowVouchersBanner() == "null") {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
......@@ -1058,7 +1060,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
return 0
}
} else if (section == 1) {
if (swiftApi().getShowVouchersBanner() == "true") {
if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
return 1
} else {
return 0
......@@ -1112,7 +1114,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
return 0.0
}
} else if (indexPath.section == 1) {
if (swiftApi().getShowVouchersBanner() == "true") {
if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
return UITableView.automaticDimension
} else {
return 0.0
......@@ -1208,7 +1210,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
return nil
}
} else if (section == 1) {
// if (swiftApi().getShowVouchersBanner() == "true") {
// if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 70))
// view.backgroundColor = .clear
......@@ -1268,7 +1270,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
return 0.0
}
} else if (section == 1) {
// if (swiftApi().getShowVouchersBanner() == "true") {
// if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
// return 70.0
// } else {
return 0.0
......@@ -1322,7 +1324,7 @@ extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
} else if (indexPath.section == 1) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletVouchersBannerTableViewCellId", for: indexPath) as! WalletVouchersBannerTableViewCell
cell.configureCell(showSeparator: self.showActiveCouponsBanners)
cell.configureCell(showSeparator: self.showActiveCouponsBanners, active: swiftApi().getShowVouchersBanner() == "true")
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletSpinnerTableViewCellId", for: indexPath) as! WalletSpinnerTableViewCell
......
......@@ -15,6 +15,7 @@ import UIKit
@IBOutlet weak var voucherBannerIconImage: UIImageView!
@IBOutlet weak var voucherBannerLabel: UILabel!
@IBOutlet weak var voucherBannerArrowImage: UIImageView!
@IBOutlet weak var voucherCountView: UIView!
public override func awakeFromNib() {
super.awakeFromNib()
......@@ -35,7 +36,10 @@ import UIKit
voucherBannerIconImage.image = UIImage(named: "wallet_voucher", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
voucherBannerArrowImage.image = UIImage(named: "arrow_right_black", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
voucherBannerLabel.text = "Ενημερώσου για το υπόλοιπο επιδότησης"
// voucherBannerLabel.text = "Ενημερώσου για το υπόλοιπο επιδότησης"
voucherCountView.layer.cornerRadius = 4.0
voucherCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
......@@ -44,7 +48,7 @@ import UIKit
// Configure the view for the selected state
}
func configureCell(showSeparator: Bool) {
func configureCell(showSeparator: Bool, active: Bool) {
if (showSeparator == true) {
separatorView.isHidden = false
separatorTopSpace.constant = 25
......@@ -53,6 +57,25 @@ import UIKit
separatorView.isHidden = true
separatorTopSpace.constant = 0
}
if (active == true) {
voucherBannerView.backgroundColor = .white
voucherBannerIconImage.image = voucherBannerIconImage.image?.withRenderingMode(.alwaysTemplate)
voucherBannerIconImage.tintColor = UIColor(red: 0.00, green: 0.65, blue: 0.89, alpha: 1.00)
voucherBannerLabel.text = "Ενημερώσου για το υπόλοιπο επιδότησης"
voucherBannerLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
voucherBannerLabel.frame.size.width = voucherBannerLabel.intrinsicContentSize.width
voucherCountView.isHidden = true
} else {
voucherBannerView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
voucherBannerIconImage.image = voucherBannerIconImage.image?.withRenderingMode(.alwaysTemplate)
voucherBannerIconImage.tintColor = UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)
voucherBannerLabel.text = "Διαθέσιμο υπόλοιπο"
voucherBannerLabel.textColor = UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)
voucherBannerLabel.frame.size.width = voucherBannerLabel.intrinsicContentSize.width
voucherCountView.isHidden = false
}
}
}
......
......@@ -183,11 +183,10 @@ public class swiftApi {
}
public func setVouchersFetched(_ success: Bool) -> Void {
if (success == true) {
setShowVouchersBanner("true")
} else {
setShowVouchersBanner("false")
public func setVouchersFetched(_ success: String) -> Void {
// Possible values "true", "false", "null"
if (success == "true" || success == "false" || success == "null") {
setShowVouchersBanner(success)
}
SwiftEventBus.post("vouchers_fetched")
......