AddResidentsView.swift
7.61 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
//
// AddResidentsView.swift
// InterQR-Internship
//
// Created by Дмитрий Тимофеев on 14.06.2022.
//
import UIKit
class AddResidentsView: UIView {
let blurEffect: UIVisualEffectView = {
let blur = UIBlurEffect(style: UIBlurEffect.Style.systemMaterialDark)
let obj = UIVisualEffectView(effect: blur)
obj.autoresizingMask = [.flexibleWidth, .flexibleHeight]
obj.alpha = 0.9
return obj
}()
var transparentView: UIView = {
var obj = UIView()
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 = "Add resident"
obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1)
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 = UIColor(red: 0.882, green: 0.91, blue: 0.91, alpha: 1).cgColor
obj.setImage(UIImage(named: "Close"), for: .normal)
return obj
}()
var dividingLineView: UIView = {
var view = UIView()
view.backgroundColor = UIColor(red: 246/255, green: 246/255, blue: 246/255, alpha: 1)
return view
}()
var residentNameLabel: UILabel = {
var obj = UILabel()
obj.text = "Resident name"
obj.font = .skModernist(type: .bold, ofSize: 14)
obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1)
return obj
}()
var nameTextField: UITextField = {
var obj = UITextField()
obj.backgroundColor = UIColor(red: 0.954, green: 0.954, blue: 0.954, alpha: 1)
obj.textAlignment = .left
obj.layer.cornerRadius = 15
return obj
}()
var mobileNumberLabel: UILabel = {
var obj = UILabel()
obj.text = "Mobile number"
obj.font = .skModernist(type: .bold, ofSize: 14)
obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1)
return obj
}()
var mobileNumberTextField: UITextField = {
var obj = UITextField()
obj.backgroundColor = UIColor(red: 0.954, green: 0.954, blue: 0.954, alpha: 1)
obj.textAlignment = .left
obj.layer.cornerRadius = 15
return obj
}()
var managerButton: UIButton = {
var obj = UIButton()
obj.setImage(UIImage(named: ""), for: .normal)
obj.setImage(UIImage(named: ""), for: .selected)
return obj
}()
var hiddenButton: UIButton = {
var obj = UIButton()
return obj
}()
var heartButton: UIButton = {
var obj = UIButton()
obj.setImage(UIImage(named: "Heart"), for: .normal)
obj.setImage(UIImage(named: "HeartRed"), for: .selected)
return obj
}()
var gradientBG: CAGradientLayer = {
let obj = CAGradientLayer()
var leftColor = UIColor(red: 0/255, green: 68/255, blue: 139/255, alpha: 1).cgColor
var rightColor = UIColor(red: 0/255, green: 122/255, blue: 191/255, alpha: 1).cgColor
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("Add resident", for: .normal)
obj.setTitleColor(UIColor(red: 1, green: 1, blue: 1, alpha: 1), for: .normal)
obj.titleLabel?.font = .skModernist(type: .bold, ofSize: 16)
obj.setTitleColor(.cyan, for: .normal)
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() {
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)
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.top.equalToSuperview().offset(174)
// $0.bottom.equalToSuperview().offset(-201)
$0.centerY.equalToSuperview()
}
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)
}
managerButton.snp.makeConstraints {
$0.leading.equalToSuperview().offset(29)
$0.top.equalTo(mobileNumberTextField.snp.bottom).offset(30)
}
hiddenButton.snp.makeConstraints {
$0.top.equalTo(managerButton)
$0.leading.equalTo(managerButton.snp.trailing).offset(24)
}
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(45)
}
}
override func layoutSubviews() {
super.layoutSubviews()
gradientBG.frame = addResidentButton.bounds
blurEffect.frame = transparentView.bounds
}
}