From fa1a67d9572966bfac20e08f8804f8ff248258cf Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 10 Aug 2022 13:41:24 +1000 Subject: [PATCH] feat: show all media view with media & document sections from tapping All Media nav button --- .../AllMediaViewController.swift | 13 +++++++++++++ .../MediaPageViewController.swift | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Session/Media Viewing & Editing/AllMediaViewController.swift b/Session/Media Viewing & Editing/AllMediaViewController.swift index 77d61f636..ecf9bef7a 100644 --- a/Session/Media Viewing & Editing/AllMediaViewController.swift +++ b/Session/Media Viewing & Editing/AllMediaViewController.swift @@ -184,6 +184,19 @@ extension AllMediaViewController: MediaTileViewControllerDelegate { } } +// MARK: - UIViewControllerTransitioningDelegate + +extension AllMediaViewController: UIViewControllerTransitioningDelegate { + public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + return self.mediaTitleViewController.animationController(forPresented: presented, presenting: presenting, source: source) + } + + public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + return self.mediaTitleViewController.animationController(forDismissed: dismissed) + } +} + + // MARK: - MediaPresentationContextProvider extension AllMediaViewController: MediaPresentationContextProvider { diff --git a/Session/Media Viewing & Editing/MediaPageViewController.swift b/Session/Media Viewing & Editing/MediaPageViewController.swift index 53ecb371b..42639b2a9 100644 --- a/Session/Media Viewing & Editing/MediaPageViewController.swift +++ b/Session/Media Viewing & Editing/MediaPageViewController.swift @@ -458,7 +458,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou // MediaTileViewController then just pop/dismiss the screen guard let presentingNavController: UINavigationController = (self.presentingViewController as? UINavigationController), - !(presentingNavController.viewControllers.last is MediaTileViewController) + !(presentingNavController.viewControllers.last is AllMediaViewController) else { guard self.navigationController?.viewControllers.count == 1 else { self.navigationController?.popViewController(animated: true) @@ -471,7 +471,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou // Otherwise if we came via the conversation screen we need to push a new // instance of MediaTileViewController - let tileViewController: MediaTileViewController = MediaGalleryViewModel.createMediaTileViewController( + let allMediaViewController: AllMediaViewController = MediaGalleryViewModel.createAllMediaViewController( threadId: self.viewModel.threadId, threadVariant: self.viewModel.threadVariant, focusedAttachmentId: currentItem.attachment.id, @@ -479,9 +479,9 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou ) let navController: MediaGalleryNavigationController = MediaGalleryNavigationController() - navController.viewControllers = [tileViewController] + navController.viewControllers = [allMediaViewController] navController.modalPresentationStyle = .overFullScreen - navController.transitioningDelegate = tileViewController + navController.transitioningDelegate = allMediaViewController self.navigationController?.present(navController, animated: true) }