diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Book/View/BookViewController.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Book/View/BookViewController.swift
index 459397d9..055acad2 100644
--- a/MemorialHouse/MHPresentation/MHPresentation/Source/Book/View/BookViewController.swift
+++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Book/View/BookViewController.swift
@@ -35,14 +35,20 @@ final class BookViewController: UIViewController {
setup()
configureNavigationBar()
configureConstraints()
- input.send(.viewDidLoad)
+ }
+
+ override func viewWillAppear(_ animated: Bool) {
+ super.viewWillAppear(animated)
+
+ input.send(.loadBook)
}
// MARK: - Binding
private func bind() {
let output = viewModel.transform(input: input.eraseToAnyPublisher())
- output.receive(on: DispatchQueue.main)
+ output
+ .receive(on: DispatchQueue.main)
.sink { [weak self] event in
switch event {
case .setBookTitle(let bookTitle):
@@ -50,6 +56,8 @@ final class BookViewController: UIViewController {
case .loadFirstPage(let page):
guard let page else { return }
self?.configureFirstPageViewController(firstPage: page)
+ case .moveToEdit(let bookID):
+ self?.presentEditBookView(bookID: bookID)
}
}
.store(in: &cancellables)
@@ -94,8 +102,8 @@ final class BookViewController: UIViewController {
title: "수정",
normal: normalAttributes,
selected: selectedAttributes
- ) {
- // TODO: - 추후 책 속지 수정 페이지로 넘어가는 로직 필요
+ ) { [weak self] in
+ self?.input.send(.editBook)
}
}
@@ -119,6 +127,18 @@ final class BookViewController: UIViewController {
return ReadPageViewController(viewModel: readPageViewModel)
}
+
+ // MARK: - PresentEditBookView
+ private func presentEditBookView(bookID: UUID) {
+ do {
+ let editBookViewModelFactory = try DIContainer.shared.resolve(EditBookViewModelFactory.self)
+ let editBookViewModel = editBookViewModelFactory.make(bookID: bookID)
+ let editBookViewController = EditBookViewController(viewModel: editBookViewModel, mode: .modify)
+ navigationController?.pushViewController(editBookViewController, animated: true)
+ } catch {
+ MHLogger.error(error)
+ }
+ }
}
// MARK: - UIPageViewControllerDelegate
diff --git a/MemorialHouse/MHPresentation/MHPresentation/Source/Book/ViewModel/BookViewModel.swift b/MemorialHouse/MHPresentation/MHPresentation/Source/Book/ViewModel/BookViewModel.swift
index ca1b4b41..14f7d57f 100644
--- a/MemorialHouse/MHPresentation/MHPresentation/Source/Book/ViewModel/BookViewModel.swift
+++ b/MemorialHouse/MHPresentation/MHPresentation/Source/Book/ViewModel/BookViewModel.swift
@@ -4,14 +4,16 @@ import Combine
public final class BookViewModel: ViewModelType {
enum Input {
- case viewDidLoad
+ case loadBook
case loadPreviousPage
case loadNextPage
+ case editBook
}
enum Output {
case setBookTitle(with: String?)
case loadFirstPage(page: Page?)
+ case moveToEdit(bookID: UUID)
}
private let fetchBookUseCase: FetchBookUseCase
@@ -32,11 +34,10 @@ public final class BookViewModel: ViewModelType {
self.identifier = identifier
}
- @MainActor
func transform(input: AnyPublisher) -> AnyPublisher