WalletVouchersBannerTableViewCell.swift
4.59 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
//
// WalletVouchersBannerTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 23/10/23.
//
import UIKit
import SwiftEventBus
@objc public class WalletVouchersBannerTableViewCell: UITableViewCell {
@IBOutlet weak var separatorView: UIView!
@IBOutlet weak var separatorTopSpace: NSLayoutConstraint!
@IBOutlet weak var sectionTitleLabel: UILabel!
@IBOutlet weak var voucherBannerView: UIView!
@IBOutlet weak var voucherBannerIconImage: UIImageView!
@IBOutlet weak var voucherBannerLabel: UILabel!
@IBOutlet weak var voucherBannerArrowImage: UIImageView!
@IBOutlet weak var voucherCountView: UIView!
let language = swiftApi().getLanguage()
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
sectionTitleLabel.text = language == "en" ? "Subsidy balance" : "Υπόλοιπο επιδότησης"
voucherBannerView.layer.cornerRadius = 16.0
voucherBannerView.layer.borderWidth = 1
voucherBannerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// Add shadow
voucherBannerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
voucherBannerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
voucherBannerView.layer.shadowOpacity = 1.0
voucherBannerView.layer.shadowRadius = 1.0
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 = "Ενημερώσου για το υπόλοιπο επιδότησης"
voucherCountView.layer.cornerRadius = 4.0
// voucherCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
voucherCountView.backgroundColor = UIColor(rgb: 0xE20074)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(showSeparator: Bool, active: Bool) {
if (showSeparator == true) {
separatorView.isHidden = false
separatorTopSpace.constant = 25
} else {
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 = language == "en" ? "Check the available balance" : "Δες το διαθέσιμο υπόλοιπο"
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 = language == "en" ? "Available balance" : "Διαθέσιμο υπόλοιπο"
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
}
setupAccessibilty(active: active, buttonTitle: voucherBannerLabel.text ?? "")
}
func setupAccessibilty (active: Bool ,buttonTitle: String) {
// Disable accessibility for the whole cell
self.isAccessibilityElement = false
sectionTitleLabel.isAccessibilityElement = true
voucherBannerView.isAccessibilityElement = true
voucherBannerView.accessibilityLabel = buttonTitle + (!active ? ", 0" : "") + (!active ? ", Ανενεργό" : "")
voucherBannerView.accessibilityHint = "Διπλό πάτημα για άνοιγμα"
voucherBannerView.accessibilityTraits = .button
}
}