Manos Chorianopoulos

refactor Wallet badges

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 7
8 import UIKit 8 import UIKit
9 9
10 -class ActiveCodeTableViewCell: UITableViewCell { 10 +@objc public class ActiveCodeTableViewCell: UITableViewCell {
11 @IBOutlet weak var activeCodeView: UIView! 11 @IBOutlet weak var activeCodeView: UIView!
12 @IBOutlet weak var activeCodeViewHeight: NSLayoutConstraint! 12 @IBOutlet weak var activeCodeViewHeight: NSLayoutConstraint!
13 @IBOutlet weak var activeCodesCountLabel: UILabel! 13 @IBOutlet weak var activeCodesCountLabel: UILabel!
...@@ -21,7 +21,7 @@ class ActiveCodeTableViewCell: UITableViewCell { ...@@ -21,7 +21,7 @@ class ActiveCodeTableViewCell: UITableViewCell {
21 21
22 public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() 22 public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
23 23
24 - override func awakeFromNib() { 24 + public override func awakeFromNib() {
25 super.awakeFromNib() 25 super.awakeFromNib()
26 26
27 // TODO: DELETE ===> 27 // TODO: DELETE ===>
...@@ -176,7 +176,7 @@ class ActiveCodeTableViewCell: UITableViewCell { ...@@ -176,7 +176,7 @@ class ActiveCodeTableViewCell: UITableViewCell {
176 } 176 }
177 } 177 }
178 178
179 - override func setSelected(_ selected: Bool, animated: Bool) { 179 + public override func setSelected(_ selected: Bool, animated: Bool) {
180 super.setSelected(selected, animated: animated) 180 super.setSelected(selected, animated: animated)
181 181
182 // Configure the view for the selected state 182 // Configure the view for the selected state
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
8 import Foundation 8 import Foundation
9 import UIKit 9 import UIKit
10 10
11 -class UnifiedCouponsTableViewCell: UITableViewCell { 11 +@objc public class UnifiedCouponsTableViewCell: UITableViewCell {
12 @IBOutlet weak var couponBgImage: UIImageView! 12 @IBOutlet weak var couponBgImage: UIImageView!
13 @IBOutlet weak var couponImage: UIImageView! 13 @IBOutlet weak var couponImage: UIImageView!
14 @IBOutlet weak var borderView: UIView! 14 @IBOutlet weak var borderView: UIView!
......
...@@ -7,17 +7,91 @@ ...@@ -7,17 +7,91 @@
7 7
8 import UIKit 8 import UIKit
9 9
10 -class WalletBadgesTableViewCell: UITableViewCell { 10 +@objc public class WalletBadgesTableViewCell: UITableViewCell {
11 + @IBOutlet weak var rewardsLabel: UILabel!
12 + @IBOutlet weak var badgeLinesImage: UIImageView!
13 + @IBOutlet weak var sumBadgeImage: UIImageView!
14 + @IBOutlet weak var sumBadgeLabel: UILabel!
15 + @IBOutlet weak var dfyBadgeImage: UIImageView!
16 + @IBOutlet weak var dfyBadgeLabel: UILabel!
17 + @IBOutlet weak var couponBadgeImage: UIImageView!
18 + @IBOutlet weak var couponBadgeLabel: UILabel!
19 + @IBOutlet weak var marketBadgeImage: UIImageView!
20 + @IBOutlet weak var marketBadgeLabel: UILabel!
11 21
12 - override func awakeFromNib() { 22 + public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
23 +
24 + public override func awakeFromNib() {
13 super.awakeFromNib() 25 super.awakeFromNib()
14 // Initialization code 26 // Initialization code
27 +
28 + sumBadgeImage.image = UIImage(named: "wallet_summary", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
29 + badgeLinesImage.image = UIImage(named: "wallet_badge_lines", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
30 +
31 + rewardsLabel.text = "COSMOTE Επιβράβευση"
15 } 32 }
16 33
17 - override func setSelected(_ selected: Bool, animated: Bool) { 34 + public override func setSelected(_ selected: Bool, animated: Bool) {
18 super.setSelected(selected, animated: animated) 35 super.setSelected(selected, animated: animated)
19 36
20 // Configure the view for the selected state 37 // Configure the view for the selected state
21 } 38 }
22 39
40 + func configureCell(totalCouponValue: Float, totalCouponDiscount: Float, unifiedCouponsDiscount: Float) {
41 +
42 + let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
43 +// sumRewards = Float(round(100 * sumRewards) / 100)
44 + var sumRewardsString = "0"
45 + sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
46 + sumBadgeLabel.text = sumRewardsString + "€"
47 +
48 + // ===
49 +
50 + if (totalCouponValue == 0.0) {
51 + dfyBadgeImage.image = UIImage(named: "wallet_dfy_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
52 + dfyBadgeLabel.isHidden = true
53 +
54 + } else {
55 + dfyBadgeImage.image = UIImage(named: "wallet_dfy_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
56 + dfyBadgeLabel.isHidden = false
57 + }
58 +
59 + let totalCouponValueFixed = Float(round(100 * totalCouponValue) / 100)
60 + var totalCouponValueString = "0"
61 + totalCouponValueString = String(format: "%.2f", totalCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
62 + dfyBadgeLabel.text = totalCouponValueString + "€"
63 +
64 + // ===
65 +
66 + if (loyaltyBadge._couponCount == 0) {
67 + couponBadgeImage.image = UIImage(named: "wallet_coupons_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
68 + couponBadgeLabel.isHidden = true
69 + } else {
70 + couponBadgeImage.image = UIImage(named: "wallet_coupons_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
71 + couponBadgeLabel.isHidden = false
72 + }
73 +
74 + var totalCouponDiscountString = "0"
75 + totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
76 + couponBadgeLabel.text = totalCouponDiscountString + "€"
77 +
78 + // ===
79 +
80 + let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
81 + var marketDiscountString = "0"
82 + marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
83 +
84 + self.marketBadgeLabel.text = marketDiscountString + "€"
85 +
86 + if (unifiedCouponsDiscount == 0.0) {
87 + marketBadgeImage.image = UIImage(named: "wallet_market_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
88 + marketBadgeLabel.isHidden = true
89 +
90 + } else {
91 + marketBadgeImage.image = UIImage(named: "wallet_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
92 + marketBadgeLabel.isHidden = false
93 + }
94 +
95 + }
96 +
23 } 97 }
......