PayloadViewController.swift
2.89 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
//
// PayloadViewController.swift
// browser
//
// Created by Artem Talko on 25.09.2023.
//
import UIKit
final class PayloadViewController: UIViewController {
private let mainView = PayloadView()
private let data = StringConstants.payloadViewControllerData
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = ColorConstants.lightGray
initViewController()
}
private func initViewController() {
setupTableView()
addTargets()
navigationController?.isNavigationBarHidden = true
}
override func loadView() {
view = mainView
}
init(){
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
NotificationCenter.default.removeObserver(self)
}
}
extension PayloadViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "AdvantagesTableViewCell") as?
AdvantagesTableViewCell else {
return UITableViewCell() }
cell.advantagesCellLabel.text = data[indexPath.row]
cell.selectionStyle = .none
return cell
}
private func setupTableView() {
mainView.advantagesTableView.dataSource = self
mainView.advantagesTableView.delegate = self
mainView.advantagesTableView.register(AdvantagesTableViewCell.self, forCellReuseIdentifier: StringConstants.advantagesTableViewCell)
}
}
//MARK: - Action
extension PayloadViewController {
@objc
private func getStartedButtonTapped(_ sender: UIButton) {
navigationController?.popViewController(animated: false)
}
@objc
private func textPressed(_ sender: UITapGestureRecognizer) {
let termsViewController = TermsViewController()
termsViewController.modalPresentationStyle = .fullScreen
present(termsViewController, animated: true)
}
private func addTargets() {
mainView.getStartedButton.addTarget(self, action: #selector(getStartedButtonTapped(_ :)), for: .touchUpInside)
mainView.privacyLabelView.isUserInteractionEnabled = true
mainView.privacyLabelView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(textPressed(_:))))
GestureSetup()
}
private func GestureSetup() {
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(textPressed(_ :)))
mainView.infoLabel.addGestureRecognizer(tapGesture)
}
}