Newer
Older
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
import UIKit
import Theme
import Shared
import Combine
import Defaults
import DependencyInjection
public final class TermsConditionsController: UIViewController {
@Dependency var coordinator: TermsCoordinator
@Dependency var statusBarController: StatusBarStyleControlling
@KeyObject(.acceptedTerms, defaultValue: false) var didAcceptTerms: Bool
lazy private var screenView = TermsConditionsView()
private let ndf: String?
private var cancellables = Set<AnyCancellable>()
public init(_ ndf: String?) {
self.ndf = ndf
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) { nil }
public override func loadView() {
view = screenView
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
statusBarController.style.send(.darkContent)
navigationController?.navigationBar.customize(translucent: true)
}
public override func viewDidLoad() {
super.viewDidLoad()
navigationItem.backButtonTitle = ""
let backButton = UIButton()
backButton.setImage(Asset.navigationBarBack.image, for: .normal)
backButton.tintColor = Asset.neutralActive.color
backButton.imageView?.contentMode = .center
backButton.snp.makeConstraints { $0.width.equalTo(50) }
backButton
.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
navigationController?.popViewController(animated: true)
}.store(in: &cancellables)
navigationItem.leftBarButtonItem = UIBarButtonItem(
customView: UIStackView(arrangedSubviews: [backButton])
)
screenView.radioComponent
.radioButton.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
screenView.radioComponent.isEnabled.toggle()
screenView.nextButton.isEnabled = screenView.radioComponent.isEnabled
}.store(in: &cancellables)
screenView.nextButton
.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
didAcceptTerms = true
if let ndf = ndf {
coordinator.presentUsername(ndf, self)
} else {
coordinator.presentChatList(self)
}
}.store(in: &cancellables)
screenView.showTermsButton
.publisher(for: .touchUpInside)
.receive(on: DispatchQueue.main)
.sink { _ in
// TODO
}.store(in: &cancellables)
}
}