7
7
8
8
import UIKit
9
9
10
+ import Combine
10
11
import SnapKit
11
12
import Then
12
13
@@ -20,7 +21,11 @@ final class FourthOnboardingViewController: UIViewController {
20
21
private let onboardingModel : [ FourthOnboardingModel ] = FourthOnboardingModel . items
21
22
private var dataSource : UICollectionViewDiffableDataSource < Section , FourthOnboardingModel > ! = nil
22
23
private lazy var safeArea = self . view. safeAreaLayoutGuide
23
- private weak var coordinator : AuthCoordinator ?
24
+
25
+ private let viewModel : any FourthOnboardingViewModel
26
+ private var cancelBag = Set < AnyCancellable > ( )
27
+
28
+ private let buttonDidTapped = PassthroughSubject < Void , Never > ( )
24
29
25
30
// MARK: - UI Components
26
31
@@ -30,8 +35,8 @@ final class FourthOnboardingViewController: UIViewController {
30
35
31
36
// MARK: - init
32
37
33
- init ( coordinator : AuthCoordinator ) {
34
- self . coordinator = coordinator
38
+ init ( viewModel : some FourthOnboardingViewModel ) {
39
+ self . viewModel = viewModel
35
40
super. init ( nibName: nil , bundle: nil )
36
41
}
37
42
@@ -49,6 +54,7 @@ final class FourthOnboardingViewController: UIViewController {
49
54
setLayout ( )
50
55
setupDataSource ( )
51
56
reloadData ( )
57
+ setBindings ( )
52
58
}
53
59
}
54
60
@@ -59,6 +65,7 @@ extension FourthOnboardingViewController {
59
65
collectionView. register ( SubOnboardingCollectionViewCell . self, forCellWithReuseIdentifier: SubOnboardingCollectionViewCell . identifier)
60
66
collectionView. register ( OnboardingHeaderView . self, forSupplementaryViewOfKind: UICollectionView . elementKindSectionHeader, withReuseIdentifier: OnboardingHeaderView . identifier)
61
67
}
68
+
62
69
private func setUI( ) {
63
70
view. backgroundColor = . ntdBlack
64
71
@@ -67,6 +74,7 @@ extension FourthOnboardingViewController {
67
74
$0. bounces = false
68
75
$0. isScrollEnabled = false
69
76
}
77
+
70
78
nextButton. do {
71
79
$0. configuration? . image = . splashBack
72
80
$0. configuration? . title = I18N . fourthButton
@@ -137,12 +145,19 @@ extension FourthOnboardingViewController {
137
145
let layout = UICollectionViewCompositionalLayout ( section: section)
138
146
return layout
139
147
}
148
+
149
+ private func setBindings( ) {
150
+ let input = FourthOnboardingViewModelInput (
151
+ buttonDidTapped: buttonDidTapped
152
+ )
153
+ _ = viewModel. transform ( input: input)
154
+ }
140
155
}
141
156
extension FourthOnboardingViewController {
142
157
@objc
143
158
private func buttonTapped( ) {
144
159
AmplitudeAnalyticsService . shared. send ( event: AnalyticsEvent . OnboardingClick. clickOnboardingNext4)
145
160
146
- self . coordinator ? . showFifthOnboardingViewController ( )
161
+ self . buttonDidTapped . send ( )
147
162
}
148
163
}
0 commit comments