HomeTableViewCell.swift
3.22 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
//
// HomeTableViewCell.swift
// InterQR-Internship
//
// Created by Дмитрий Тимофеев on 08.06.2022.
//
import UIKit
class HomeTableViewCell: UITableViewCell {
static let id = String(describing: HomeTableViewCell.self)
var containerView: UIView = {
var obj = UIView()
obj.layer.cornerRadius = 15
obj.layer.borderWidth = 1
obj.layer.borderColor = .BorderColor.lightGrey
return obj
}()
var leftStatusImage: UIImageView = {
var obj = UIImageView()
obj.image = UIImage(named: .Image.leftBlue)
obj.contentMode = .scaleAspectFill
return obj
}()
var doorNameLabel: UILabel = {
var obj = UILabel()
obj.font = .skModernist(type: .bold, ofSize: 16)
obj.textColor = .TextColor.darkBlue
obj.text = .Text.frontDoor
return obj
}()
var doorLocationLabel: UILabel = {
var obj = UILabel()
obj.textColor = .TextColor.lightGrey
obj.font = .skModernist(type: .regular, ofSize: 14)
obj.text = .Text.home
return obj
}()
var lockStatusLabel: UILabel = {
var obj = UILabel()
obj.textColor = .TextColor.darkBlue
obj.font = .skModernist(type: .bold, ofSize: 15)
obj.text = .Text.locked
return obj
}()
var rightStatusImage: UIImageView = {
var obj = UIImageView()
obj.image = UIImage(named: .Image.rightStatus)
return obj
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup() {
selectionStyle = .none
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)
}
}
}