PageView.swift
2.56 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
//
// PageView.swift
// Pro-Seecurity-VPN
//
// Created by Volodymyr Kolomyltsev on 12/22/23.
//
import Foundation
import UIKit
import SnapKit
class PageView: UIView {
var model: OnboardingType? {
didSet {
handleUI(model: model!)
}
}
private let containerView: UIView = {
let obj = UIView()
return obj
}()
private let imgView: UIImageView = {
let obj = UIImageView()
obj.contentMode = .scaleAspectFill
return obj
}()
private let titleLbl: UILabel = {
let obj = UILabel()
obj.lineBreakMode = .byWordWrapping
obj.font = .systemFont(ofSize: 26, weight: .bold)
obj.numberOfLines = 2
obj.textAlignment = .center
return obj
}()
private let subTitleLbl: UILabel = {
let obj = UILabel()
obj.font = .systemFont(ofSize: 15, weight: .regular)
obj.lineBreakMode = .byWordWrapping
obj.numberOfLines = 3
obj.textAlignment = .center
return obj
}()
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setup() {
backgroundColor = .clear
addSubview(containerView)
containerView.addSubview(imgView)
addSubview(titleLbl)
addSubview(subTitleLbl)
containerView.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview()
make.height.equalTo(220.sizeH)
make.top.equalToSuperview()
make.bottom.equalTo(titleLbl.snp.top).offset(-48.sizeH)
}
imgView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
titleLbl.snp.makeConstraints { make in
make.bottom.equalTo(subTitleLbl.snp.top).offset(-8.sizeH)
make.centerX.equalTo(containerView)
make.width.equalTo(300.sizeW)
}
subTitleLbl.snp.makeConstraints { make in
// make.top.equalTo(titleLbl.snp.bottom).offset(8.sizeH)
make.width.equalTo(300.sizeW)
make.centerX.equalTo(titleLbl)
make.bottom.equalToSuperview()
}
}
}
//MARK: Helpers
extension PageView {
private func handleUI(model: OnboardingType) {
imgView.image = UIImage(named: model.imgString)
titleLbl.text = model.title
subTitleLbl.text = model.subTitle
}
}