AddResidentsView.swift
8.29 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
//
// AddResidentsView.swift
// InterQR-Internship
//
// Created by Дмитрий Тимофеев on 14.06.2022.
//
import UIKit
class AddResidentsView: UIView {
var isShow: Bool = false
let blurEffect: UIVisualEffectView = {
let blur = UIBlurEffect(style: UIBlurEffect.Style.systemMaterialDark)
let obj = UIVisualEffectView(effect: blur)
obj.autoresizingMask = [.flexibleWidth, .flexibleHeight]
obj.alpha = 0.9
obj.isUserInteractionEnabled = true
return obj
}()
let transparentView: UIView = {
var obj = UIView()
obj.isUserInteractionEnabled = true
obj.backgroundColor = .black
obj.alpha = 0.5
return obj
}()
var containerView: UIView = {
var obj = UIView()
obj.clipsToBounds = true
obj.layer.cornerRadius = 15
obj.backgroundColor = .white
return obj
}()
var addResidentLabeL: UILabel = {
var obj = UILabel()
obj.text = .Text.addResident
obj.textColor = .TextColor.darkBlue
obj.font = .skModernist(type: .bold, ofSize: 24)
return obj
}()
var closeButton: UIButton = {
var obj = UIButton()
obj.layer.cornerRadius = 13
obj.layer.borderWidth = 1
obj.layer.borderColor = .BorderColor.lightGrey
obj.setImage(UIImage(named: .Image.close), for: .normal)
return obj
}()
var dividingLineView: UIView = {
var view = UIView()
view.backgroundColor = .Background.lightGrey
return view
}()
var residentNameLabel: UILabel = {
var obj = UILabel()
obj.text = .Text.residentName
obj.font = .skModernist(type: .bold, ofSize: 14)
obj.textColor = .TextColor.darkBlue
return obj
}()
var nameTextField: TextFieldWithPadding = {
var obj = TextFieldWithPadding()
obj.backgroundColor = .TextFieldColor.general
obj.textAlignment = .left
obj.layer.cornerRadius = 15
obj.placeholder = .Text.enterResidentName
obj.font = .skModernist(type: .regular, ofSize: 14)
obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 22)
obj.returnKeyType = .done
return obj
}()
var mobileNumberLabel: UILabel = {
var obj = UILabel()
obj.text = .Text.mobileNumber
obj.font = .skModernist(type: .bold, ofSize: 14)
obj.textColor = .TextColor.darkBlue
return obj
}()
var mobileNumberTextField: TextFieldWithPadding = {
var obj = TextFieldWithPadding()
obj.backgroundColor = .TextFieldColor.general
obj.textAlignment = .left
obj.layer.cornerRadius = 15
obj.font = .skModernist(type: .regular, ofSize: 14)
obj.textPadding = UIEdgeInsets(top: 0, left: 22, bottom: 0, right: 45)
obj.placeholder = .Text.enterResidentNumber
obj.keyboardType = .phonePad
return obj
}()
let contactListButton: UIButton = {
let obj = UIButton()
obj.setImage(UIImage(named: .Image.threeUsers), for: .normal)
return obj
}()
var managerButton: SquereCheckbox = {
var obj = SquereCheckbox()
obj.checkboxTitle = .Text.manager
return obj
}()
var hiddenButton: SquereCheckbox = {
var obj = SquereCheckbox()
obj.checkboxTitle = .Text.hidden
return obj
}()
var heartButton: UIButton = {
var obj = UIButton()
obj.setImage(UIImage(named: .Image.heart), for: .normal)
obj.setImage(UIImage(named: .Image.heartRed), for: .selected)
return obj
}()
var gradientBG: CAGradientLayer = {
let obj = CAGradientLayer()
var leftColor = CGColor.GradientBlue.left
var rightColor = CGColor.GradientBlue.right
obj.colors = [leftColor, rightColor]
obj.startPoint = CGPoint(x: 0, y: 0.5)
obj.endPoint = CGPoint(x: 1, y: 0.5)
return obj
}()
var addResidentButton: UIButton = {
var obj = UIButton()
obj.setTitle(.Text.addResident, for: .normal)
obj.setTitleColor(.white, for: .normal)
obj.titleLabel?.font = .skModernist(type: .bold, ofSize: 16)
obj.clipsToBounds = true
obj.layer.masksToBounds = true
return obj
}()
override init(frame: CGRect) {
super.init(frame: frame)
layout()
backgroundColor = .clear
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func layout() {
isUserInteractionEnabled = true
addResidentButton.layer.insertSublayer(gradientBG, at: 0)
addSubview(transparentView)
transparentView.addSubview(blurEffect)
addSubview(containerView)
containerView.addSubview(addResidentLabeL)
containerView.addSubview(closeButton)
containerView.addSubview(dividingLineView)
containerView.addSubview(residentNameLabel)
containerView.addSubview(nameTextField)
containerView.addSubview(mobileNumberLabel)
containerView.addSubview(mobileNumberTextField)
mobileNumberTextField.addSubview(contactListButton)
containerView.addSubview(managerButton)
containerView.addSubview(hiddenButton)
containerView.addSubview(heartButton)
containerView.addSubview(addResidentButton)
transparentView.snp.makeConstraints {
$0.leading.top.trailing.bottom.equalToSuperview()
}
containerView.snp.makeConstraints {
$0.leading.trailing.equalToSuperview().inset(25)
$0.centerY.equalTo(transparentView.snp.centerY)
}
addResidentLabeL.snp.makeConstraints {
$0.top.equalToSuperview().offset(34)
$0.leading.equalToSuperview().offset(28)
}
closeButton.snp.makeConstraints {
$0.centerY.equalTo(addResidentLabeL)
$0.trailing.equalToSuperview().offset(-30)
$0.height.width.equalTo(45)
}
dividingLineView.snp.makeConstraints {
$0.trailing.leading.equalToSuperview()
$0.height.equalTo(1)
$0.top.equalTo(addResidentLabeL.snp.bottom).offset(34)
}
residentNameLabel.snp.makeConstraints {
$0.top.equalTo(dividingLineView.snp.bottom).offset(24)
$0.leading.equalToSuperview().offset(44)
}
nameTextField.snp.makeConstraints {
$0.leading.trailing.equalToSuperview().inset(30)
$0.top.equalTo(residentNameLabel.snp.bottom).offset(10)
$0.height.equalTo(47)
}
mobileNumberLabel.snp.makeConstraints {
$0.leading.equalTo(residentNameLabel.snp.leading)
$0.top.equalTo(nameTextField.snp.bottom).offset(15)
}
mobileNumberTextField.snp.makeConstraints {
$0.leading.trailing.equalToSuperview().inset(30)
$0.top.equalTo(mobileNumberLabel.snp.bottom).offset(10)
$0.height.equalTo(47)
}
contactListButton.snp.makeConstraints {
$0.height.width.equalTo(24)
$0.centerY.equalToSuperview()
$0.trailing.equalToSuperview().offset(-19)
}
managerButton.snp.makeConstraints {
$0.leading.equalToSuperview().offset(29)
$0.top.equalTo(mobileNumberTextField.snp.bottom).offset(30)
$0.height.equalTo(20)
}
hiddenButton.snp.makeConstraints {
$0.top.equalTo(managerButton)
$0.leading.equalTo(managerButton.snp.trailing).offset(24)
$0.height.equalTo(20)
}
heartButton.snp.makeConstraints {
$0.top.equalTo(managerButton)
$0.trailing.equalToSuperview().offset(-32.5)
}
addResidentButton.snp.makeConstraints {
$0.top.equalTo(managerButton.snp.bottom).offset(43)
$0.leading.trailing.bottom.equalToSuperview()
$0.height.equalTo(64)
}
}
override func layoutSubviews() {
super.layoutSubviews()
gradientBG.frame = addResidentButton.bounds
blurEffect.frame = transparentView.bounds
}
}