AnalysisItemViewCell.swift
1.8 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
//
// AnalysisItemViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisItemViewCell: UITableViewCell {
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// date
dateLabel.textColor = UIColor(rgb: 0x435563)
// title
titleLabel.textColor = UIColor(rgb: 0x435563)
// price
priceLabel.textColor = UIColor(rgb: 0x435563)
// subtitle
subtitleLabel.textColor = UIColor(rgb: 0x8B97A3)
}
}
extension AnalysisItemViewCell {
func configureCell(item: swiftApi.SharingCouponModel) {
// TODO: this is not optimal. we need a static date formatter. we cannot instantiate a new object each time we render a new item.
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
if let date = item.date {
let dateString = dateFormatter.string(from: date)
dateLabel.text = dateString
} else {
dateLabel.text = ""
}
//itemImage.image =
titleLabel.text = item.name
priceLabel.text = String(format: "%.2f€", item.discount)
if ("sent" == item.sharingType) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι προς @%", "69740000000")
} else if ("received" == item.sharingType) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι από @%", "69740000000")
}
}
}