@@ -290,10 +290,10 @@ final class DetailCoordinator: Coordinator {
290290 navigationController. present ( controller, animated: true , completion: nil )
291291 }
292292
293- func createPDFController( key: String , parentKey: String ? , library: Library , url: URL , page: Int ? = nil , preselectedAnnotationKey: String ? = nil ) -> NavigationViewController {
294- let navigationController = NavigationViewController ( )
293+ func createPDFController( key: String , parentKey: String ? , library: Library , url: URL , page: Int ? = nil , preselectedAnnotationKey: String ? = nil ) -> DetailNavigationViewController {
294+ let navigationController = DetailNavigationViewController ( )
295295 navigationController. modalPresentationStyle = . fullScreen
296-
296+
297297 let coordinator = PDFCoordinator (
298298 key: key,
299299 parentKey: parentKey,
@@ -304,6 +304,7 @@ final class DetailCoordinator: Coordinator {
304304 navigationController: navigationController,
305305 controllers: controllers
306306 )
307+ navigationController. coordinator = coordinator
307308 coordinator. parentCoordinator = self
308309 childCoordinators. append ( coordinator)
309310 coordinator. start ( animated: false )
@@ -315,10 +316,14 @@ final class DetailCoordinator: Coordinator {
315316 guard let navigationController else { return }
316317 controllers. userControllers? . openItemsController. open ( . pdf( libraryId: library. identifier, key: key) , for: sessionIdentifier)
317318
318- let viewControllerProvider : ( ) -> UIViewController = {
319+ let viewControllerProvider : ( ) -> DetailNavigationViewController = {
319320 self . createPDFController ( key: key, parentKey: parentKey, library: library, url: url)
320321 }
321322 if let presentedViewController = navigationController. presentedViewController {
323+ if let presentedDetailNavigationController = presentedViewController as? DetailNavigationViewController {
324+ presentedDetailNavigationController. replaceContents ( with: viewControllerProvider ( ) , animated: false )
325+ return
326+ }
322327 guard let window = presentedViewController. view. window else { return }
323328 show ( viewControllerProvider: viewControllerProvider, by: navigationController, in: window, animated: false )
324329 return
@@ -471,8 +476,8 @@ extension DetailCoordinator: DetailItemsCoordinatorDelegate {
471476 tags: [ Tag ] ,
472477 title: NoteEditorState . TitleData ? ,
473478 saveCallback: @escaping NoteEditorSaveCallback
474- ) -> NavigationViewController {
475- let navigationController = NavigationViewController ( )
479+ ) -> DetailNavigationViewController {
480+ let navigationController = DetailNavigationViewController ( )
476481 navigationController. modalPresentationStyle = . fullScreen
477482 navigationController. isModalInPresentation = true
478483
@@ -487,6 +492,7 @@ extension DetailCoordinator: DetailItemsCoordinatorDelegate {
487492 sessionIdentifier: sessionIdentifier,
488493 controllers: controllers
489494 )
495+ navigationController. coordinator = coordinator
490496 coordinator. parentCoordinator = self
491497 childCoordinators. append ( coordinator)
492498 coordinator. start ( animated: false )
@@ -947,10 +953,14 @@ extension DetailCoordinator: DetailNoteEditorCoordinatorDelegate {
947953 controllers. userControllers? . openItemsController. open ( . note( libraryId: library. identifier, key: key) , for: sessionIdentifier)
948954 }
949955
950- let viewControllerProvider : ( ) -> UIViewController = {
956+ let viewControllerProvider : ( ) -> DetailNavigationViewController = {
951957 self . createNoteController ( library: library, kind: kind, text: text, tags: tags, title: title, saveCallback: amendedSaveCallback)
952958 }
953959 if let presentedViewController = navigationController. presentedViewController {
960+ if let presentedDetailNavigationController = presentedViewController as? DetailNavigationViewController {
961+ presentedDetailNavigationController. replaceContents ( with: viewControllerProvider ( ) , animated: false )
962+ return
963+ }
954964 guard let window = presentedViewController. view. window else { return }
955965 show ( viewControllerProvider: viewControllerProvider, by: navigationController, in: window, animated: false )
956966 return
0 commit comments