@@ -17,20 +17,6 @@ enum FallingCellButtonAction {
17
17
case like( IndexPath )
18
18
}
19
19
20
- enum TimerActiveAction {
21
- case viewWillDisAppear( Bool )
22
- case profileDoubleTap( Bool )
23
- case reportButtonTap( Bool )
24
- case DimViewTap( Bool )
25
-
26
- var state : Bool {
27
- switch self {
28
- case . viewWillDisAppear( let flag) , . profileDoubleTap( let flag) , . reportButtonTap( let flag) , . DimViewTap( let flag) :
29
- return flag
30
- }
31
- }
32
- }
33
-
34
20
enum AnimationAction {
35
21
case scroll, delete
36
22
}
@@ -40,6 +26,8 @@ final class FallingHomeViewController: TFBaseViewController {
40
26
private var dataSource : DataSource !
41
27
private lazy var homeView = FallingHomeView ( )
42
28
29
+ private lazy var alertContentView = TFAlertContentView ( )
30
+
43
31
init ( viewModel: FallingHomeViewModel ) {
44
32
self . viewModel = viewModel
45
33
super. init ( nibName: nil , bundle: nil )
@@ -74,23 +62,23 @@ final class FallingHomeViewController: TFBaseViewController {
74
62
let fallingCellButtonAction = PublishSubject < FallingCellButtonAction > ( )
75
63
76
64
let viewWillDisAppearTrigger = self . rx. viewWillDisAppear. map { _ in
77
- return TimerActiveAction . viewWillDisAppear ( false )
65
+ return false
78
66
} . asDriverOnErrorJustEmpty ( )
79
67
80
- let timerActiveRelay = BehaviorRelay < TimerActiveAction > ( value: . profileDoubleTap ( true ) )
68
+ let timerActiveRelay = BehaviorRelay < Bool > ( value: true )
81
69
82
70
let profileDoubleTapTriggerObserver = PublishSubject < Void > ( )
83
71
let profileDoubleTapTrigger = profileDoubleTapTriggerObserver
84
72
. withLatestFrom ( timerActiveRelay) {
85
- return TimerActiveAction . profileDoubleTap ( !$1. state )
73
+ return !$1
86
74
}
87
75
. asDriverOnErrorJustEmpty ( )
88
76
89
77
let reportButtonTapTriggerObserver = PublishSubject < Void > ( )
90
78
91
79
let reportButtonTapTrigger = reportButtonTapTriggerObserver
92
80
. withLatestFrom ( timerActiveRelay) { _, _ in
93
- return TimerActiveAction . reportButtonTap ( false )
81
+ return false
94
82
}
95
83
. asDriverOnErrorJustEmpty ( )
96
84
@@ -101,6 +89,8 @@ final class FallingHomeViewController: TFBaseViewController {
101
89
let complaintsButtonTapTrigger = PublishRelay < Void > ( )
102
90
let blockButtonTapTrigger = PublishRelay < Void > ( )
103
91
92
+ let deleteCellTrigger = Driver . merge ( complaintsButtonTapTrigger. asDriverOnErrorJustEmpty ( ) , blockButtonTapTrigger. asDriverOnErrorJustEmpty ( ) )
93
+
104
94
let input = FallingHomeViewModel . Input (
105
95
initialTrigger: initialTrigger,
106
96
timeOverTrigger: timerOverTrigger,
@@ -125,7 +115,8 @@ final class FallingHomeViewController: TFBaseViewController {
125
115
timeOverSubject: timeOverSubject,
126
116
profileDoubleTapTriggerObserver: profileDoubleTapTriggerObserver,
127
117
fallingCellButtonAction: fallingCellButtonAction,
128
- reportButtonTapTriggerObserver: reportButtonTapTriggerObserver
118
+ reportButtonTapTriggerObserver: reportButtonTapTriggerObserver,
119
+ deleteCellTrigger: deleteCellTrigger
129
120
)
130
121
}
131
122
@@ -186,45 +177,66 @@ final class FallingHomeViewController: TFBaseViewController {
186
177
}
187
178
. disposed ( by: disposeBag)
188
179
180
+ Driver . merge (
181
+ alertContentView. unpleasantPhotoButton. rx. tap. asDriver ( ) ,
182
+ alertContentView. fakeProfileButton. rx. tap. asDriver ( ) ,
183
+ alertContentView. photoTheftButton. rx. tap. asDriver ( ) ,
184
+ alertContentView. profanityButton. rx. tap. asDriver ( ) ,
185
+ alertContentView. sharingIllegalFootageButton. rx. tap. asDriver ( ) )
186
+ . do { _ in
187
+ complaintsButtonTapTrigger. accept ( ( ) )
188
+
189
+ self . homeView. makeToast ( " 신고하기가 완료되었습니다. 해당 사용자와 \n 서로 차단되며, 신고 사유는 검토 후 처리됩니다. " , duration: 3.0 , position: . bottom)
190
+
191
+ UIWindow . keyWindow? . rootViewController? . dismiss ( animated: false )
192
+ }
193
+ . drive ( )
194
+ . disposed ( by: disposeBag)
195
+
189
196
reportButtonTapTriggerObserver. asDriverOnErrorJustEmpty ( )
190
197
. do { _ in
191
198
self . showAlert (
192
- leftActionTitle: " 신고하기 " ,
193
- rightActionTitle: " 차단하기 " ,
194
- leftActionCompletion: {
195
- self . showAlert ( action: . complaints)
199
+ topActionTitle: " 신고하기 " ,
200
+ bottomActionTitle: " 차단하기 " ,
201
+ dimColor: DSKitAsset . Color. clear. color,
202
+ topActionCompletion: {
203
+ self . showAlert (
204
+ contentView: self . alertContentView,
205
+ topActionTitle: nil ,
206
+ dimColor: DSKitAsset . Color. clear. color,
207
+ bottomActionCompletion: { timerActiveRelay. accept ( true ) } ,
208
+ dimActionCompletion: { timerActiveRelay. accept ( true ) }
209
+ )
196
210
} ,
197
- rightActionCompletion : {
211
+ bottomActionCompletion : {
198
212
self . showAlert (
199
213
action: . block,
200
- leftActionCompletion: {
214
+ dimColor: DSKitAsset . Color. clear. color,
215
+ topActionCompletion: {
201
216
blockButtonTapTrigger. accept ( ( ) )
217
+
218
+ self . homeView. makeToast ( " 차단하기가 완료되었습니다. 해당 사용자와 \n 서로 차단되며 설정에서 확인 가능합니다. " , duration: 3.0 , position: . bottom)
202
219
} ,
203
- rightActionCompletion: {
204
- timerActiveRelay. accept ( . DimViewTap( true ) )
205
- }
220
+ bottomActionCompletion: { timerActiveRelay. accept ( true ) } ,
221
+ dimActionCompletion: { timerActiveRelay. accept ( true ) }
206
222
)
207
223
} ,
208
- dimActionCompletion: {
209
- timerActiveRelay. accept ( . DimViewTap( true ) )
210
- }
224
+ dimActionCompletion: { timerActiveRelay. accept ( true ) }
211
225
)
212
226
}
213
227
. drive ( )
214
228
. disposed ( by: disposeBag)
215
229
216
230
Driver . merge ( output. complaintsAction, output. blockAction)
217
231
. do { indexPath in
218
- // timerActiveRelay.accept(.DimViewTap(true))
232
+ guard let _ = self . homeView. collectionView. cellForItem ( at: indexPath) as? FallingUserCollectionViewCell else { return }
233
+
219
234
self . deleteItems ( indexPath)
235
+
220
236
DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.5 ) {
221
237
timeOverSubject. onNext ( . delete)
222
- timerActiveRelay. accept ( . DimViewTap ( true ) )
238
+ timerActiveRelay. accept ( true )
223
239
}
224
-
225
- // timerActiveRelay.accept(.DimViewTap(true))
226
-
227
-
228
240
}
229
241
. drive ( )
230
242
. disposed ( by: disposeBag)
0 commit comments