WalletBannersTableViewCell.swift
9.92 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//
// WalletBannersTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/4/23.
//
import UIKit
@objc public class WalletBannersTableViewCell: UITableViewCell {
@IBOutlet weak var sumBannerArrowImage: UIImageView!
@IBOutlet weak var sumBannerInnerView: UIView!
@IBOutlet weak var sumBadgeImage: UIImageView!
@IBOutlet weak var sumBadgeLabel: UILabel!
@IBOutlet weak var sumBannerLabel: UILabel!
@IBOutlet weak var dfyBannerView: UIView!
@IBOutlet weak var dfyBannerHeight: NSLayoutConstraint!
@IBOutlet weak var dfyBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var dfyBannerInnerView: UIView!
@IBOutlet weak var dfyBadgeImage: UIImageView!
@IBOutlet weak var dfyBadgeLabel: UILabel!
@IBOutlet weak var dfyBannerLabel: UILabel!
@IBOutlet weak var gfyBannerView: UIView!
@IBOutlet weak var gfyBannerHeight: NSLayoutConstraint!
@IBOutlet weak var gfyBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var gfyBannerInnerView: UIView!
@IBOutlet weak var couponBadgeImage: UIImageView!
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var gfyBannerLabel: UILabel!
@IBOutlet weak var marketBannerView: UIView!
@IBOutlet weak var marketBannerHeight: NSLayoutConstraint!
@IBOutlet weak var marketBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var marketBannerInnerView: UIView!
@IBOutlet weak var marketBadgeImage: UIImageView!
@IBOutlet weak var marketBadgeLabel: UILabel!
@IBOutlet weak var marketBannerLabel: UILabel!
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
sumBadgeImage.image = UIImage(named: "wallet_summary_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeImage.image = UIImage(named: "wallet_dfy_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeImage.image = UIImage(named: "wallet_coupons_4", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeImage.image = UIImage(named: "wallet_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
sumBannerInnerView.layer.cornerRadius = 16.5
sumBannerInnerView.layer.borderWidth = 1
sumBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
dfyBannerInnerView.layer.cornerRadius = 16.5
dfyBannerInnerView.layer.borderWidth = 1
dfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
gfyBannerInnerView.layer.cornerRadius = 16.5
gfyBannerInnerView.layer.borderWidth = 1
gfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
marketBannerInnerView.layer.cornerRadius = 16.5
marketBannerInnerView.layer.borderWidth = 1
marketBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
dfyBannerView.isHidden = true
dfyBannerHeight.constant = 0.0
dfyBannerTopSpace.constant = 0.0
gfyBannerView.isHidden = true
gfyBannerHeight.constant = 0.0
gfyBannerTopSpace.constant = 0.0
marketBannerView.isHidden = true
marketBannerHeight.constant = 0.0
marketBannerTopSpace.constant = 0.0
}
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, forYouExpanded: Bool) {
if (forYouExpanded == false) {
sumBannerArrowImage.image = UIImage(named: "ic_down_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBannerView.isHidden = true
dfyBannerHeight.constant = 0.0
dfyBannerTopSpace.constant = 0.0
gfyBannerView.isHidden = true
gfyBannerHeight.constant = 0.0
gfyBannerTopSpace.constant = 0.0
marketBannerView.isHidden = true
marketBannerHeight.constant = 0.0
marketBannerTopSpace.constant = 0.0
} else {
sumBannerArrowImage.image = UIImage(named: "ic_up_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBannerView.isHidden = false
dfyBannerHeight.constant = 80.0
dfyBannerTopSpace.constant = 8.0
gfyBannerView.isHidden = false
gfyBannerHeight.constant = 80.0
gfyBannerTopSpace.constant = 8.0
marketBannerView.isHidden = false
marketBannerHeight.constant = 80.0
marketBannerTopSpace.constant = 8.0
}
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && unifiedCouponsDiscount == 0.0) {
sumBannerArrowImage.isHidden = true
} else {
sumBannerArrowImage.isHidden = false
}
// ===
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// if (sumRewards == 0.0) {
// sumBannerArrowImage.isHidden = true
// } else {
// sumBannerArrowImage.isHidden = false
// }
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
let sumNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let sumBoldText = sumRewardsString + "€"
let sumNormalText2 = " στο For You!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 14) ?? UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 14) ?? UIFont.boldSystemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let sumAttributedString = NSMutableAttributedString(string:sumNormalText1, attributes:attrRegular)
let sumBoldString = NSMutableAttributedString(string: sumBoldText, attributes:attrBold)
let sumNormalString = NSMutableAttributedString(string:sumNormalText2, attributes:attrRegular)
sumAttributedString.append(sumBoldString)
sumAttributedString.append(sumNormalString)
sumBannerLabel.attributedText = sumAttributedString
// ===
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 + "€"
let dfyNormalText1 = "Έχεις κερδίσει "
let dfyBoldText = totalCouponValueString + "€"
let dfyNormalText2 = " με το DEALS for YOU!"
let dfyAttributedString = NSMutableAttributedString(string:dfyNormalText1, attributes:attrRegular)
let dfyBoldString = NSMutableAttributedString(string: dfyBoldText, attributes:attrBold)
let dfyNormalString = NSMutableAttributedString(string:dfyNormalText2, attributes:attrRegular)
dfyAttributedString.append(dfyBoldString)
dfyAttributedString.append(dfyNormalString)
dfyBannerLabel.attributedText = dfyAttributedString
// ===
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
couponBadgeLabel.text = totalCouponDiscountString + "€"
let gfyNormalText1 = "Έχεις κερδίσει "
let gfyBoldText = totalCouponDiscountString + "€"
let gfyNormalText2 = " με το GIFTS for YOU!"
let gfyAttributedString = NSMutableAttributedString(string:gfyNormalText1, attributes:attrRegular)
let gfyBoldString = NSMutableAttributedString(string: gfyBoldText, attributes:attrBold)
let gfyNormalString = NSMutableAttributedString(string:gfyNormalText2, attributes:attrRegular)
gfyAttributedString.append(gfyBoldString)
gfyAttributedString.append(gfyNormalString)
gfyBannerLabel.attributedText = gfyAttributedString
// ===
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 + "€"
let marketNormalText1 = "Έχεις κερδίσει "
let marketBoldText = marketDiscountString + "€"
let marketNormalText2 = " με τα SuperMarket Deals!"
let marketAttributedString = NSMutableAttributedString(string:marketNormalText1, attributes:attrRegular)
let marketBoldString = NSMutableAttributedString(string: marketBoldText, attributes:attrBold)
let marketNormalString = NSMutableAttributedString(string:marketNormalText2, attributes:attrRegular)
marketAttributedString.append(marketBoldString)
marketAttributedString.append(marketNormalString)
marketBannerLabel.attributedText = marketAttributedString
}
}