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