CodeVerificationView.swift
7.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
//
// CodeVerificationView.swift
// InterQR-Internship
//
// Created by Дмитрий Тимофеев on 03.06.2022.
//
import UIKit
class CodeVerificationView: UIView {
var containerView: UIView = {
var obj = UIView()
return obj
}()
var backButton: UIButton = {
var obj = UIButton()
obj.setImage(UIImage(named: "BackPointer"), for: .normal)
obj.backgroundColor = .white
obj.layer.borderColor = UIColor(red: 224/255, green: 231/255, blue: 232/255, alpha: 1).cgColor
obj.layer.cornerRadius = 13
obj.layer.borderWidth = 1
return obj
}()
var logoImage: UIImageView = {
var obj = UIImageView()
obj.image = UIImage(named: "InterQR")
return obj
}()
var shieldImage: UIImageView = {
var obj = UIImageView()
obj.image = UIImage(named: "Lock")
return obj
}()
var descriptionLabel: UILabel = {
var obj = UILabel()
obj.font = UIFont(name: SkModernistFontType.bold.rawValue, size: 35)
obj.text = "Enter your\nverification code"
obj.numberOfLines = 2
return obj
}()
var textField: UITextField = {
let obj = UITextField()
obj.returnKeyType = .done
obj.keyboardType = .numberPad
obj.becomeFirstResponder()
obj.isHidden = true
return obj
}()
var firstDigitLabel: UILabel = {
let obj = UILabel()
obj.font = .skModernist(type: .bold, ofSize: 16)
obj.textColor = .black
obj.textAlignment = .center
obj.backgroundColor = UIColor(red: 0.954, green: 0.954, blue: 0.954, alpha: 1)
obj.layer.cornerRadius = 15
obj.clipsToBounds = true
return obj
}()
var secondDigitLabel: UILabel = {
let obj = UILabel()
obj.font = .skModernist(type: .bold, ofSize: 16)
obj.textColor = .black
obj.textAlignment = .center
obj.backgroundColor = UIColor(red: 0.954, green: 0.954, blue: 0.954, alpha: 1)
obj.layer.cornerRadius = 15
obj.clipsToBounds = true
return obj
}()
var thirdDigitLabel: UILabel = {
let obj = UILabel()
obj.font = .skModernist(type: .bold, ofSize: 16)
obj.textColor = .black
obj.textAlignment = .center
obj.backgroundColor = UIColor(red: 0.954, green: 0.954, blue: 0.954, alpha: 1)
obj.layer.cornerRadius = 15
obj.clipsToBounds = true
return obj
}()
var fourthDigitLabel: UILabel = {
let obj = UILabel()
obj.font = .skModernist(type: .bold, ofSize: 16)
obj.textColor = .black
obj.textAlignment = .center
obj.backgroundColor = UIColor(red: 0.954, green: 0.954, blue: 0.954, alpha: 1)
obj.layer.cornerRadius = 15
obj.clipsToBounds = true
return obj
}()
var errorAlertLabel: UILabel = {
var obj = UILabel()
obj.text = "Please, enter valid verification code"
obj.font = UIFont(name: SkModernistFontType.regular.rawValue, size: 14)
obj.textColor = UIColor(red: 255/255, green: 0/255, blue: 46/255, alpha: 1)
obj.isHidden = true
return obj
}()
var verifyButton: UIButton = {
var obj = UIButton()
obj.setImage(UIImage(named: "RectangleWithShadow"), for: .normal)
return obj
}()
var verifyLabel: UILabel = {
var obj = UILabel()
obj.font = UIFont(name: SkModernistFontType.bold.rawValue, size: 16)
obj.textColor = .white
obj.text = "Verify"
return obj
}()
var tickImage: UIImageView = {
var obj = UIImageView()
obj.image = UIImage(named: "Tick")
return obj
}()
override init(frame: CGRect) {
super.init(frame: frame)
layout()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func layout() {
backgroundColor = .white
addSubview(textField)
addSubview(backButton)
addSubview(logoImage)
addSubview(shieldImage)
addSubview(containerView)
containerView.addSubview(descriptionLabel)
containerView.addSubview(firstDigitLabel)
containerView.addSubview(secondDigitLabel)
containerView.addSubview(thirdDigitLabel)
containerView.addSubview(fourthDigitLabel)
containerView.addSubview(errorAlertLabel)
containerView.addSubview(verifyButton)
verifyButton.addSubview(verifyLabel)
verifyButton.addSubview(tickImage)
backButton.snp.makeConstraints {
$0.top.equalTo(snp.top).offset(66)
$0.leading.equalTo(snp.leading).offset(22)
$0.height.width.equalTo(45)
}
logoImage.snp.makeConstraints {
$0.leading.equalTo(backButton.snp.trailing).offset(20)
$0.centerY.equalTo(backButton)
}
shieldImage.snp.makeConstraints {
$0.top.equalTo(backButton.snp.bottom).offset(25)
$0.right.equalTo(snp.right).offset(-101)
}
containerView.snp.makeConstraints {
$0.top.equalTo(backButton.snp.bottom).offset(227)
$0.leading.trailing.equalToSuperview()
$0.height.equalTo(300)
}
descriptionLabel.snp.makeConstraints {
$0.leading.equalTo(containerView.snp.leading).offset(20)
$0.top.equalTo(containerView.snp.top)
}
firstDigitLabel.snp.makeConstraints {
$0.leading.equalTo(containerView.snp.leading).offset(25)
$0.top.equalTo(descriptionLabel.snp.bottom).offset(28)
$0.height.equalTo(55)
}
secondDigitLabel.snp.makeConstraints {
$0.leading.equalTo(firstDigitLabel.snp.trailing).offset(12)
$0.centerY.equalTo(firstDigitLabel)
$0.width.equalTo(firstDigitLabel.snp.width)
$0.height.equalTo(55)
}
thirdDigitLabel.snp.makeConstraints {
$0.leading.equalTo(secondDigitLabel.snp.trailing).offset(12)
$0.centerY.equalTo(firstDigitLabel)
$0.width.equalTo(firstDigitLabel.snp.width)
$0.height.equalTo(55)
}
fourthDigitLabel.snp.makeConstraints {
$0.leading.equalTo(thirdDigitLabel.snp.trailing).offset(12)
$0.centerY.equalTo(firstDigitLabel)
$0.trailing.equalTo(containerView.snp.trailing).offset(-25)
$0.width.equalTo(firstDigitLabel.snp.width)
$0.height.equalTo(55)
}
errorAlertLabel.snp.makeConstraints {
$0.top.equalTo(firstDigitLabel.snp.bottom).offset(8)
$0.leading.equalTo(firstDigitLabel.snp.leading)
}
verifyButton.snp.makeConstraints {
$0.top.equalTo(firstDigitLabel.snp.bottom).offset(67)
$0.left.right.equalToSuperview()
}
verifyLabel.snp.makeConstraints {
$0.left.equalToSuperview().offset(49)
$0.top.equalToSuperview().offset(22)
}
tickImage.snp.makeConstraints {
$0.right.equalToSuperview().offset(-47)
$0.centerY.equalTo(verifyLabel)
}
}
}