ResidentTableViewCell.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
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
//
// ResidentTableViewCell.swift
// InterQR-Internship
//
// Created by Дмитрий Тимофеев on 21.06.2022.
//
import UIKit
class ResidentTableViewCell: UITableViewCell {
static let id = String(describing: ResidentTableViewCell.self)
var containerView: UIView = {
var obj = UIView()
obj.layer.cornerRadius = 15
obj.layer.borderWidth = 1
obj.layer.borderColor = .BorderColor.lightGrey
return obj
}()
var serialNumberView: UIImageView = {
let obj = UIImageView()
obj.layer.cornerRadius = 21.5
obj.backgroundColor = .blue
return obj
}()
var serialNumberLabel: UILabel = {
let obj = UILabel()
obj.font = .skModernist(type: .bold, ofSize: 14)
obj.textColor = .white
return obj
}()
var nameLabel: UILabel = {
var obj = UILabel()
obj.textColor = .TextColor.darkBlue
obj.font = .skModernist(type: .bold, ofSize: 16)
obj.text = "John Doe"
return obj
}()
var phoneNumberLabel: UILabel = {
var obj = UILabel()
obj.textColor = .TextColor.lightGrey
obj.font = .skModernist(type: .regular, ofSize: 14)
obj.text = "+38095"
return obj
}()
var managerButton: SquereCheckbox = {
var obj = SquereCheckbox()
obj.checkboxTitle = "Manager"
obj.setTitleColor(.TextColor.lightGrey, for: .normal)
obj.setTitleColor(.TextColor.darkBlue, for: .selected)
obj.isSelected = false
return obj
}()
var hiddenButton: SquereCheckbox = {
var obj = SquereCheckbox()
obj.checkboxTitle = "Hidden"
obj.setTitleColor(.TextColor.lightGrey, for: .normal)
obj.setTitleColor(.TextColor.darkBlue, for: .selected)
obj.isSelected = false
return obj
}()
var heartButton: UIButton = {
var obj = UIButton()
obj.setImage(UIImage(named: "Heart"), for: .normal)
obj.setImage(UIImage(named: "RedHeart"), for: .selected)
return obj
}()
var removeCellButton: UIButton = {
var obj = UIButton()
obj.setImage(UIImage(named: "Bin"), for: .normal)
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() {
selectionStyle = .none
contentView.addSubview(containerView)
containerView.addSubview(serialNumberView)
serialNumberView.addSubview(serialNumberLabel)
containerView.addSubview(nameLabel)
containerView.addSubview(phoneNumberLabel)
containerView.addSubview(managerButton)
containerView.addSubview(hiddenButton)
containerView.addSubview(heartButton)
containerView.addSubview(removeCellButton)
containerView.snp.makeConstraints {
$0.leading.trailing.equalToSuperview().inset(25)
$0.bottom.top.equalToSuperview().inset(8)
}
serialNumberView.snp.makeConstraints {
$0.height.width.equalTo(41)
$0.leading.equalToSuperview().offset(23)
$0.top.equalToSuperview().offset(19)
}
serialNumberLabel.snp.makeConstraints {
$0.centerX.centerY.equalToSuperview()
}
nameLabel.snp.makeConstraints {
$0.leading.equalTo(serialNumberView.snp.trailing).offset(18)
$0.top.equalToSuperview().offset(22)
}
removeCellButton.snp.makeConstraints {
$0.centerY.equalTo(nameLabel.snp.centerY)
$0.trailing.equalToSuperview().offset(-22.5)
}
phoneNumberLabel.snp.makeConstraints {
$0.leading.equalTo(nameLabel.snp.leading)
$0.top.equalTo(nameLabel.snp.bottom).offset(1)
}
managerButton.snp.makeConstraints {
$0.top.equalTo(phoneNumberLabel.snp.bottom).offset(30)
$0.leading.equalToSuperview().offset(24)
$0.height.equalTo(20)
}
hiddenButton.snp.makeConstraints {
$0.leading.equalTo(managerButton.snp.trailing).offset(23)
$0.centerY.equalTo(managerButton)
$0.height.equalTo(20)
}
heartButton.snp.makeConstraints {
$0.centerY.equalTo(hiddenButton)
$0.bottom.equalToSuperview().offset(-18)
$0.trailing.equalToSuperview().offset(-22)
}
}
}