PayloadView.swift
5.46 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
//
// PayloadView.swift
// browser
//
// Created by Artem Talko on 25.09.2023.
//
import UIKit
final class PayloadView: UIView {
let logoImageView: UIImageView = {
let obj = UIImageView()
obj.image = UIImage(named: "Gotoweb")
obj.contentMode = .scaleAspectFit
return obj
}()
let phoneImageView: UIImageView = {
let obj = UIImageView()
obj.image = UIImage(named: "Phone")
obj.contentMode = .scaleAspectFit
return obj
}()
let zoomedTabImageView: UIImageView = {
let obj = UIImageView()
obj.image = UIImage(named: "ZoomedTab")
obj.contentMode = .scaleAspectFit
return obj
}()
let infoLabel: UILabel = {
let obj = UILabel()
obj.text = StringConstants.ourBrowser
obj.font = FontConstants.regularFont_12
obj.numberOfLines = 0
return obj
}()
let advantagesTableView: UITableView = {
let obj = UITableView()
obj.backgroundColor = .clear
obj.isScrollEnabled = false
obj.separatorStyle = .none
return obj
}()
let gradientLayer = CAGradientLayer()
let getStartedButton: UIButton = {
let obj = UIButton()
obj.setTitle("Get started", for: .normal)
obj.titleLabel?.font = FontConstants.semiboldFont_17
obj.setTitleColor(.white, for: .normal)
obj.layer.cornerRadius = 10
obj.layer.masksToBounds = true
return obj
}()
let privacyLabelView: UILabel = {
let obj = UILabel()
obj.textAlignment = .center
let fullText = "By starting, you agree to our Terms and Condition and Privacy Policy."
let attributedText = NSMutableAttributedString(string: fullText)
attributedText.addAttribute(.foregroundColor, value: UIColor(red: 0.349, green: 0.565, blue: 1, alpha: 1).cgColor, range: NSRange(location: fullText.range(of: "Terms and Condition")?.lowerBound.utf16Offset(in: fullText) ?? 0, length: "Terms and Condition".count))
attributedText.addAttribute(.foregroundColor, value: UIColor(red: 0.349, green: 0.565, blue: 1, alpha: 1).cgColor, range: NSRange(location: fullText.range(of: "Privacy Policy")?.lowerBound.utf16Offset(in: fullText) ?? 0, length: "Privacy Policy".count))
obj.attributedText = attributedText
obj.font = FontConstants.regularFont_12
obj.numberOfLines = 0
obj.isUserInteractionEnabled = true
return obj
}()
override init (frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
gradientLayer.frame = getStartedButton.bounds
}
private func setup() {
addSubview(logoImageView)
addSubview(phoneImageView)
addSubview(zoomedTabImageView)
addSubview(infoLabel)
addSubview(advantagesTableView)
addSubview(getStartedButton)
addSubview(privacyLabelView)
setupConstraints()
gradientSetup()
}
func setupConstraints() {
logoImageView.snp.makeConstraints { make in
make.top.equalTo(safeAreaLayoutGuide.snp.top).offset(16.sizeH)
make.leading.trailing.equalToSuperview().inset(143.sizeW)
make.height.equalTo(26.sizeH)
}
phoneImageView.snp.makeConstraints { make in
make.top.equalTo(logoImageView.snp.bottom).offset(16.sizeH)
make.leading.trailing.equalToSuperview().inset(90.sizeW)
make.height.equalTo(355.sizeH)
}
zoomedTabImageView.snp.makeConstraints { make in
make.top.equalTo(phoneImageView.snp.top).offset(119.sizeH)
make.leading.equalTo(phoneImageView.snp.leading).offset(91.sizeW)
make.trailing.equalToSuperview().offset(-71)
make.bottom.equalTo(phoneImageView.snp.bottom).offset(-104.sizeH)
}
infoLabel.snp.makeConstraints { make in
make.top.equalTo(phoneImageView.snp.bottom).offset(16.sizeH)
make.leading.trailing.equalToSuperview().inset(55.sizeW)
}
advantagesTableView.snp.makeConstraints { make in
make.top.equalTo(infoLabel.snp.bottom).offset(16.sizeH)
make.leading.equalToSuperview().offset(55.sizeW)
make.trailing.equalToSuperview().offset(-92.sizeW)
make.bottom.equalTo(getStartedButton.snp.top).offset(-38.sizeH)
}
getStartedButton.snp.makeConstraints { make in
make.top.equalTo(advantagesTableView.snp.bottom).offset(24.sizeH)
make.leading.trailing.equalToSuperview().inset(32.sizeW)
make.height.equalTo(40.sizeH)
}
privacyLabelView.snp.makeConstraints { make in
make.top.equalTo(getStartedButton.snp.bottom).offset(16.sizeH)
make.leading.trailing.equalToSuperview().inset(32.sizeW)
make.bottom.equalTo(safeAreaLayoutGuide).offset(-16.sizeH)
}
}
}
//MARK: Gradient
extension PayloadView {
private func gradientSetup() {
getStartedButton.layer.insertSublayer(gradientLayer, at: 0)
gradientLayer.colors = [UIColor(red: 0.349, green: 0.565, blue: 1, alpha: 1).cgColor, UIColor(red: 0.349, green: 0.565, blue: 1, alpha: 0.7).cgColor]
gradientLayer.locations = [0.0, 1.0]
}
}