diff --git a/Packages/GalleryVC/Sources/GalleryVC/Content/FallbackGalleryContentViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/Content/FallbackGalleryContentViewController.swift index 12d28da8..81fd0ebb 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/Content/FallbackGalleryContentViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/Content/FallbackGalleryContentViewController.swift @@ -82,8 +82,8 @@ public class FallbackGalleryNavigationController: UINavigationController, Galler nil } - public var canAnimateFromSourceView: Bool { - false + public var presentationAnimation: GalleryContentPresentationAnimation { + .fade } } diff --git a/Packages/GalleryVC/Sources/GalleryVC/Content/ImageGalleryContentViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/Content/ImageGalleryContentViewController.swift index 37191dbc..e24895af 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/Content/ImageGalleryContentViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/Content/ImageGalleryContentViewController.swift @@ -97,6 +97,10 @@ open class ImageGalleryContentViewController: UIViewController, GalleryContentVi return [image] } + public var presentationAnimation: GalleryContentPresentationAnimation { + gifController != nil ? .fromSourceViewWithoutSnapshot : .fromSourceView + } + public func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) { if #available(iOS 16.0, macCatalyst 17.0, *), let analysisInteraction { diff --git a/Packages/GalleryVC/Sources/GalleryVC/Content/LoadingGalleryContentViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/Content/LoadingGalleryContentViewController.swift index 48509d64..82751d5a 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/Content/LoadingGalleryContentViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/Content/LoadingGalleryContentViewController.swift @@ -27,8 +27,8 @@ public class LoadingGalleryContentViewController: UIViewController, GalleryConte wrapped?.caption ?? fallbackCaption } - public var canAnimateFromSourceView: Bool { - wrapped?.canAnimateFromSourceView ?? true + public var presentationAnimation: GalleryContentPresentationAnimation { + wrapped?.presentationAnimation ?? .fade } public init(caption: String?, provider: @escaping () async -> (any GalleryContentViewController)?) { diff --git a/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift index 4afa609d..bcc85732 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/Content/VideoGalleryContentViewController.swift @@ -157,6 +157,10 @@ open class VideoGalleryContentViewController: UIViewController, GalleryContentVi [] } + public var presentationAnimation: GalleryContentPresentationAnimation { + .fromSourceViewWithoutSnapshot + } + private lazy var overlayVC = VideoOverlayViewController(player: player) public var contentOverlayAccessoryViewController: UIViewController? { overlayVC diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryContentViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryContentViewController.swift index e2bbbfa5..7485d19b 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryContentViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryContentViewController.swift @@ -15,7 +15,7 @@ public protocol GalleryContentViewController: UIViewController { var caption: String? { get } var contentOverlayAccessoryViewController: UIViewController? { get } var bottomControlsAccessoryViewController: UIViewController? { get } - var canAnimateFromSourceView: Bool { get } + var presentationAnimation: GalleryContentPresentationAnimation { get } func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) func galleryContentDidAppear() @@ -31,8 +31,8 @@ public extension GalleryContentViewController { nil } - var canAnimateFromSourceView: Bool { - true + var presentationAnimation: GalleryContentPresentationAnimation { + .fromSourceView } func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) { @@ -44,3 +44,9 @@ public extension GalleryContentViewController { func galleryContentWillDisappear() { } } + +public enum GalleryContentPresentationAnimation { + case fade + case fromSourceView + case fromSourceViewWithoutSnapshot +} diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift index b26ad4b5..c14ef041 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift @@ -30,7 +30,7 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans let itemViewController = from.currentItemViewController - if !itemViewController.content.canAnimateFromSourceView || (UIAccessibility.prefersCrossFadeTransitions && interactiveVelocity == nil) { + if itemViewController.content.presentationAnimation == .fade || (UIAccessibility.prefersCrossFadeTransitions && interactiveVelocity == nil) { animateCrossFadeTransition(using: transitionContext) return } @@ -47,7 +47,11 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans container.addSubview(to.view) } - let sourceSnapshot = sourceView.snapshotView(afterScreenUpdates: false) + let sourceSnapshot: UIView? = if itemViewController.content.presentationAnimation == .fromSourceViewWithoutSnapshot { + nil + } else { + sourceView.snapshotView(afterScreenUpdates: false) + } if let sourceSnapshot { let snapshotContainer = sourceView.ancestorForInsertingSnapshot snapshotContainer.addSubview(sourceSnapshot) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift index 8b7143e1..e508a6f8 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift @@ -25,7 +25,7 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated let itemViewController = to.currentItemViewController - if !itemViewController.content.canAnimateFromSourceView || UIAccessibility.prefersCrossFadeTransitions { + if itemViewController.content.presentationAnimation == .fade || UIAccessibility.prefersCrossFadeTransitions { animateCrossFadeTransition(using: transitionContext) return } @@ -33,7 +33,11 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated // Try to effectively "fade out" anything that's on top of the source view. // The 0.1 duration makes this happen faster than the rest of the animation, // and so less noticeable. - let sourceSnapshot = sourceView.snapshotView(afterScreenUpdates: false) + let sourceSnapshot: UIView? = if itemViewController.content.presentationAnimation == .fromSourceViewWithoutSnapshot { + nil + } else { + sourceView.snapshotView(afterScreenUpdates: false) + } if let sourceSnapshot { let snapshotContainer = sourceView.ancestorForInsertingSnapshot snapshotContainer.addSubview(sourceSnapshot) diff --git a/Tusker/Screens/Gallery/GifvGalleryContentViewController.swift b/Tusker/Screens/Gallery/GifvGalleryContentViewController.swift index a5d73a1b..efc91b97 100644 --- a/Tusker/Screens/Gallery/GifvGalleryContentViewController.swift +++ b/Tusker/Screens/Gallery/GifvGalleryContentViewController.swift @@ -69,4 +69,8 @@ class GifvGalleryContentViewController: UIViewController, GalleryContentViewCont [VideoActivityItemSource(asset: controller.item.asset, url: url)] } + var presentationAnimation: GalleryContentPresentationAnimation { + .fromSourceViewWithoutSnapshot + } + }