HomeTableViewCell.swift
3.47 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
//
// HomeTableViewCell.swift
// InterQR-Internship
//
// Created by Дмитрий Тимофеев on 08.06.2022.
//
import UIKit
class HomeTableViewCell: UITableViewCell {
static let id = "HomeTableViewCell-ID"
var containerView: UIView = {
var obj = UIView()
obj.layer.cornerRadius = 15
obj.layer.borderWidth = 1
obj.layer.borderColor = UIColor(red: 0.89, green: 0.918, blue: 0.918, alpha: 1).cgColor
return obj
}()
var leftStatusImage: UIImageView = {
var obj = UIImageView()
obj.image = UIImage(named: "LeftBlue")
obj.contentMode = .scaleAspectFill
return obj
}()
var doorNameLabel: UILabel = {
var obj = UILabel()
obj.font = .skModernist(type: .bold, ofSize: 16)
obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1)
obj.text = "Front Door"
return obj
}()
var doorLocationLabel: UILabel = {
var obj = UILabel()
obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1)
obj.font = .skModernist(type: .regular, ofSize: 14)
obj.text = "Home"
return obj
}()
var lockStatusLabel: UILabel = {
var obj = UILabel()
obj.textColor = UIColor(red: 0, green: 0.267, blue: 0.545, alpha: 1)
obj.font = .skModernist(type: .bold, ofSize: 15)
obj.text = "Locked"
return obj
}()
var rightStatusImage: UIImageView = {
var obj = UIImageView()
obj.image = UIImage(named: "RightBlue")
return obj
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
layout()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func layout() {
addSubview(containerView)
containerView.addSubview(leftStatusImage)
containerView.addSubview(doorNameLabel)
containerView.addSubview(doorLocationLabel)
containerView.addSubview(lockStatusLabel)
containerView.addSubview(rightStatusImage)
containerView.snp.makeConstraints {
$0.leading.trailing.equalToSuperview()
$0.bottom.equalToSuperview().offset(-8)
$0.top.equalToSuperview().offset(8)
}
leftStatusImage.snp.makeConstraints {
$0.top.equalTo(containerView.snp.top).offset(19)
$0.leading.equalTo(containerView.snp.leading).offset(23)
$0.height.width.equalTo(41)
}
doorNameLabel.snp.makeConstraints {
$0.top.equalTo(snp.top).offset(22)
$0.leading.equalTo(leftStatusImage.snp.trailing).offset(14)
}
doorLocationLabel.snp.makeConstraints {
$0.top.equalTo(doorNameLabel.snp.bottom)
$0.leading.equalTo(doorNameLabel.snp.leading)
}
lockStatusLabel.snp.makeConstraints {
$0.bottom.equalTo(snp.bottom).offset(-15)
$0.centerX.equalTo(snp.centerX)
}
rightStatusImage.snp.makeConstraints {
$0.trailing.equalTo(snp.trailing).offset(-16)
$0.top.equalTo(snp.top).offset(19)
}
}
// func configureWithItem(_ item: DoorsModel) {
// doorTypeLabel.text = item.purpose
// doorLocationLabel.text = item.type
// configureStatus(status: item.lockStatus)
// rightStatusImageView.isHidden = false
// }
}