Skip to content

Commit aff28fb

Browse files
committed
[BOOK-284] refactor: adjust navigation flow between Record and Book Detail screens
1 parent 419e0be commit aff28fb

2 files changed

Lines changed: 44 additions & 11 deletions

File tree

src/Projects/BKPresentation/Sources/MainFlow/BookDetail/Coordinator/BookDetailCoordinator.swift

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ final class BookDetailCoordinator: Coordinator {
99

1010
private let isbn: String
1111
private let userBookId: String
12+
private weak var bookDetailViewController: BookDetailViewController?
1213

1314
init(
1415
parentCoordinator: Coordinator?,
@@ -30,6 +31,7 @@ final class BookDetailCoordinator: Coordinator {
3031
)
3132
)
3233
viewController.coordinator = self
34+
bookDetailViewController = viewController
3335
navigationController.pushViewController(viewController, animated: true)
3436
}
3537
}
@@ -52,15 +54,35 @@ extension BookDetailCoordinator {
5254
}
5355

5456
func didTapCell(recordId: String) {
55-
let viewController = NoteCompletionViewController(
56-
viewModel: NoteCompletionViewModel(recordId: recordId)
57-
)
58-
let noteNavigationController = UINavigationController(rootViewController: viewController)
59-
57+
let noteNavigationController = UINavigationController()
6058
noteNavigationController.modalPresentationStyle = .fullScreen
59+
60+
let noteCompletionCoordinator = NoteCompletionCoordinator(
61+
parentCoordinator: self,
62+
navigationController: noteNavigationController,
63+
recordId: recordId
64+
)
65+
addChildCoordinator(noteCompletionCoordinator)
66+
noteCompletionCoordinator.start()
67+
6168
navigationController.present(noteNavigationController, animated: true)
6269
}
6370

71+
func didTapEditButton(recordId: String, from presentingController: UIViewController) {
72+
let editNavigationController = UINavigationController()
73+
editNavigationController.modalPresentationStyle = .fullScreen
74+
75+
let noteEditCoordinator = NoteEditCoordinator(
76+
parentCoordinator: self,
77+
navigationController: editNavigationController,
78+
recordId: recordId
79+
)
80+
addChildCoordinator(noteEditCoordinator)
81+
noteEditCoordinator.start()
82+
83+
presentingController.present(editNavigationController, animated: true)
84+
}
85+
6486
/// 문장 카드 확인 및 공유하기 화면으로 이동합니다.
6587
func goToShareView(item: BookDetailItem) {
6688
let viewController = SentenceCardViewController(
@@ -71,4 +93,3 @@ extension BookDetailCoordinator {
7193
navigationController.pushViewController(viewController, animated: true)
7294
}
7395
}
74-

src/Projects/BKPresentation/Sources/MainFlow/Note/Coordinator/NoteCoordinator.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@ extension NoteCoordinator: AuthenticationRequiredNotifying, ErrorHandleable {
4545

4646
extension NoteCoordinator {
4747
func didCompleteNoteCreation(recordInfo: RecordInfo) {
48-
let viewController = NoteCompletionViewController(
49-
viewModel: NoteCompletionViewModel(recordId: recordInfo.recordId)
48+
let noteNavigationController = UINavigationController()
49+
noteNavigationController.modalPresentationStyle = .fullScreen
50+
51+
// ✅ 부모를 내 부모(예: BookDetailCoordinator)로 올려준다
52+
let parent = self.parentCoordinator ?? self
53+
54+
let noteCompletionCoordinator = NoteCompletionCoordinator(
55+
parentCoordinator: parent,
56+
navigationController: noteNavigationController,
57+
recordId: recordInfo.recordId
5058
)
51-
let noteNavigationController = UINavigationController(rootViewController: viewController)
5259

53-
noteNavigationController.modalPresentationStyle = .fullScreen
54-
navigationController.present(noteNavigationController, animated: true) {
60+
// 부모의 child로 달기 (addChildCoordinator는 부모 쪽 메서드여야 함)
61+
parent.addChildCoordinator(noteCompletionCoordinator)
62+
noteCompletionCoordinator.start()
63+
64+
// 프리젠터는 parent의 navigationController가 가장 안전
65+
parent.navigationController.present(noteNavigationController, animated: true) {
66+
// 이제 NoteCoordinator를 정리해도 완료 플로우는 안 죽음
5567
self.popAndFinish()
5668
}
5769
}

0 commit comments

Comments
 (0)