NewPaywallView.swift
7.35 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
//
// NewPaywallView.swift
// Pro-Seecurity-VPN
//
// Created by Volodymyr Kolomyltsev on 12/22/23.
//
import Foundation
import UIKit
import SnapKit
class OnboardingView: UIView {
private let stackView: UIStackView = {
let obj = UIStackView()
obj.axis = .horizontal
obj.distribution = .fillEqually
obj.spacing = 15.sizeW
return obj
}()
let closeButton: UIButton = {
let obj = UIButton()
obj.setImage(UIImage(systemName: "xmark"), for: .normal)
obj.contentMode = .scaleToFill
obj.tintColor = .white
return obj
}()
let backgroundImageView: UIImageView = {
let obj = UIImageView()
let imageBackground = UIImage(named: "newPaywalBackground")
obj.image = imageBackground
return obj
}()
let scrollView: UIScrollView = {
let obj = UIScrollView()
obj.isScrollEnabled = true
obj.showsHorizontalScrollIndicator = false
obj.showsVerticalScrollIndicator = false
obj.contentInsetAdjustmentBehavior = .always
obj.isPagingEnabled = true
obj.contentInset = .zero
return obj
}()
private let snapPhotoPage: PageView = {
let obj = PageView()
obj.model = .snapPhotoSlide
return obj
}()
private let submitPhotoPage: PageView = {
let obj = PageView()
obj.model = .submitPhotoSlide
return obj
}()
private let getRewardsPhotoPage: PageView = {
let obj = PageView()
obj.model = .getRewardsSlide
return obj
}()
let pageControl: UIPageControl = {
let obj = UIPageControl()
obj.numberOfPages = 3
obj.currentPage = 0
obj.clipsToBounds = true
return obj
}()
let infoLabel: UILabel = {
let obj = UILabel()
obj.text = "3 дня бесплатной пробной версии, затем $9,99 в неделю"
obj.font = .systemFont(ofSize: 12.sizeW, weight: .regular)
obj.numberOfLines = 2
obj.textAlignment = .center
return obj
}()
private let buttonsStackView: UIStackView = {
let obj = UIStackView()
obj.axis = .horizontal
obj.alignment = .center
obj.distribution = .fillEqually
obj.spacing = 6.sizeW
return obj
}()
let restoreButton: UIButton = {
let obj = UIButton()
obj.setTitle("Restore", for: .normal)
obj.setTitleColor(.white, for: .normal)
obj.setTitleColor(.white, for: .highlighted)
obj.titleLabel?.font = UIFont.systemFont(ofSize: 12.sizeW, weight: .regular)
obj.titleLabel?.lineBreakMode = .byWordWrapping
return obj
}()
let privacyButton: UIButton = {
let obj = UIButton()
obj.setTitle("Privacy", for: .normal)
obj.setTitleColor(.white, for: .normal)
obj.setTitleColor(.white, for: .highlighted)
obj.titleLabel?.font = UIFont.systemFont(ofSize: 12.sizeW, weight: .regular)
obj.titleLabel?.lineBreakMode = .byWordWrapping
return obj
}()
let termsButton: UIButton = {
let obj = UIButton()
obj.setTitle("Terms", for: .normal)
obj.setTitleColor(.white, for: .normal)
obj.setTitleColor(.white, for: .highlighted)
obj.titleLabel?.font = UIFont.systemFont(ofSize: 12.sizeW, weight: .regular)
obj.titleLabel?.lineBreakMode = .byWordWrapping
return obj
}()
let activateButton: UIButton = {
let obj = UIButton()
obj.backgroundColor = UIColor(red: 15/255, green: 125/255, blue: 255/255, alpha: 1)
obj.layer.cornerRadius = 6.sizeH
obj.titleLabel?.font = UIFont.systemFont(ofSize: 16.sizeW, weight: .bold)
obj.setTitle("Activate Now", for: .normal)
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()
// scrollView.contentInset.left = 10.sizeW
scrollView.contentSize = CGSize(width: scrollView.bounds.width*3, height: scrollView.bounds.height)
}
private func setup() {
// backgroundColor = .red
addSubview(backgroundImageView)
addSubview(scrollView)
addSubview(pageControl)
addSubview(infoLabel)
addSubview(activateButton)
addSubview(buttonsStackView)
addSubview(closeButton)
buttonsStackView.addArrangedSubview(privacyButton)
buttonsStackView.addArrangedSubview(termsButton)
buttonsStackView.addArrangedSubview(restoreButton)
scrollView.addSubview(snapPhotoPage)
scrollView.addSubview(submitPhotoPage)
scrollView.addSubview(getRewardsPhotoPage)
// scrollView.backgroundColor = .black
pageControl.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
closeButton.snp.makeConstraints { make in
make.top.equalTo(safeAreaLayoutGuide.snp.top).offset(16.sizeH)
make.leading.equalToSuperview().inset(16.sizeW)
make.height.equalTo(24.sizeH)
}
backgroundImageView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
scrollView.snp.makeConstraints { make in
make.top.equalTo(closeButton.snp.bottom).inset(-16.sizeH)
make.trailing.leading.equalToSuperview()
make.bottom.equalTo(pageControl.snp.top).offset(-16.sizeH)
}
pageControl.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalTo(activateButton.snp.top).offset(-60.sizeH)
make.height.equalTo(16.sizeH)
}
snapPhotoPage.snp.makeConstraints { make in
make.width.equalToSuperview()
make.top.equalToSuperview()
make.bottom.equalToSuperview()
make.leading.equalToSuperview()
}
submitPhotoPage.snp.makeConstraints { make in
make.width.equalToSuperview()
make.top.equalToSuperview()
make.bottom.equalToSuperview()
make.leading.equalTo(snapPhotoPage.snp.trailing)
}
getRewardsPhotoPage.snp.makeConstraints { make in
make.width.equalToSuperview()
make.top.equalToSuperview()
make.bottom.equalToSuperview()
make.leading.equalTo(submitPhotoPage.snp.trailing)
make.trailing.equalToSuperview()
}
activateButton.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview().inset(16)
make.height.equalTo(51.sizeH)
make.bottom.equalTo(infoLabel.snp.top).offset(-24.sizeH)
}
infoLabel.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview().inset(16)
make.height.equalTo(16.sizeH)
make.bottom.equalTo(buttonsStackView.snp.top).offset(-43.sizeH)
}
buttonsStackView.snp.makeConstraints { make in
make.bottom.equalTo(safeAreaLayoutGuide.snp.bottom).offset(-51.sizeH)
make.leading.trailing.equalToSuperview().inset(16)
}
}
}