@@ -168,11 +168,19 @@ final class SearchViewController: BaseViewController<SearchView>, ScreenLoggable
168168 . store ( in: & cancellable)
169169
170170 viewModel. statePublisher
171- . compactMap { $0. isUpserted }
172- . removeDuplicates ( )
171+ . compactMap { state -> ( isbn: String , status: BookRegistrationStatus ) ? in
172+ guard let isbn = state. isUpserted,
173+ let status = state. selectedStatus else {
174+ return nil
175+ }
176+ return ( isbn, status)
177+ }
178+ . removeDuplicates { previous, current in
179+ return previous. isbn == current. isbn && previous. status == current. status
180+ }
173181 . receive ( on: DispatchQueue . main)
174- . sink { [ weak self] isbn in
175- self ? . presentNoteSuggestion ( with: isbn)
182+ . sink { [ weak self] ( isbn, status ) in
183+ self ? . presentNoteSuggestion ( with: isbn, status : status )
176184 self ? . viewModel. send ( . noteSuggestionShown)
177185 }
178186 . store ( in: & cancellable)
@@ -273,32 +281,49 @@ private extension SearchViewController {
273281 viewModel. send ( . upsertBook( isbn: isbn, status: status) )
274282 }
275283
276- func presentNoteSuggestion( with isbn: String ) {
284+ func presentNoteSuggestion( with isbn: String , status : BookRegistrationStatus ) {
277285 let graphic = BKImage . Graphics. coinCheck
278286 let graphicView = UIImageView ( image: graphic)
279287 graphicView. snp. makeConstraints {
280288 $0. size. equalTo ( CGSize ( width: 120 , height: 120 ) )
281289 }
290+
291+ let sheetTitle = " 도서가 등록되었어요! "
292+ let cancelAction : ( ( ) -> Void ) ? = { [ weak self] in
293+ self ? . dismiss ( animated: true )
294+ self ? . hideLoading ( )
295+ }
296+
297+ let nextAction : ( ( ) -> Void ) ? = { [ weak self] in
298+ self ? . dismiss ( animated: true )
299+ self ? . viewModel. send ( . loadNoteFlow)
300+ self ? . hideLoading ( )
301+
302+ }
282303 logScreenView ( name: GATracking . SearchAndRegister. complete)
283304
305+ var buttonGroup : BKButtonGroup ?
306+
307+ if status == . before {
308+ buttonGroup = . singleFullButton(
309+ title: status. getCancelButtonTitle ( ) ,
310+ action: cancelAction
311+ )
312+ } else {
313+ buttonGroup = . twoButtonGroup(
314+ leftTitle: status. getCancelButtonTitle ( ) ,
315+ rightTitle: status. getNextButtonTitle ( ) ,
316+ leftAction: cancelAction,
317+ rightAction: nextAction
318+ )
319+ }
320+
284321 let sheet = BKBottomSheetViewController (
285- title: " 도서가 등록되었어요! " ,
286- subtitle: " 독서 기록을 바로 시작할까요? " ,
322+ title: sheetTitle ,
323+ subtitle: status . getSubTitle ( ) ,
287324 style: . centered,
288325 suppliedContentStyle: . upper( graphicView) ,
289- buttonConfiguration: . twoButtonGroup(
290- leftTitle: " 나중에 하기 " ,
291- rightTitle: " 기록 시작하기 " ,
292- leftAction: { [ weak self] in
293- self ? . dismiss ( animated: true )
294- self ? . hideLoading ( )
295- } ,
296- rightAction: { [ weak self] in
297- self ? . dismiss ( animated: true )
298- self ? . viewModel. send ( . loadNoteFlow)
299- self ? . hideLoading ( )
300- }
301- )
326+ buttonConfiguration: buttonGroup
302327 )
303328
304329 sheet. show ( from: self , animated: true )
0 commit comments