forked from shadowfacts/Tusker
Don't use snapshot for gallery present/dismiss transition of non-static content
This commit is contained in:
parent
a5066140fd
commit
dc01804359
|
@ -82,8 +82,8 @@ public class FallbackGalleryNavigationController: UINavigationController, Galler
|
|||
nil
|
||||
}
|
||||
|
||||
public var canAnimateFromSourceView: Bool {
|
||||
false
|
||||
public var presentationAnimation: GalleryContentPresentationAnimation {
|
||||
.fade
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)?) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -69,4 +69,8 @@ class GifvGalleryContentViewController: UIViewController, GalleryContentViewCont
|
|||
[VideoActivityItemSource(asset: controller.item.asset, url: url)]
|
||||
}
|
||||
|
||||
var presentationAnimation: GalleryContentPresentationAnimation {
|
||||
.fromSourceViewWithoutSnapshot
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue