From 4fcc32ca4bea33ba7ef71ddeb5eb555fe7f83244 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 29 Mar 2024 18:22:33 -0400 Subject: [PATCH] Fix gallery controls popping in over content after presentation --- .../GalleryPresentationAnimationController.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift index 72a3fa96d0..29dd514388 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift @@ -59,9 +59,17 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated let content = itemViewController.takeContent() content.view.translatesAutoresizingMaskIntoConstraints = true - container.addSubview(to.view) - container.addSubview(content.view) + // Use a separate dimming view from to.view, so that the gallery controls can be in front of the moving content. + let dimmingView = UIView() + dimmingView.backgroundColor = .black + dimmingView.frame = container.bounds + dimmingView.layer.opacity = 0 + container.addSubview(dimmingView) + container.addSubview(content.view) + container.addSubview(to.view) + + to.view.backgroundColor = nil to.view.layer.opacity = 0 content.view.frame = sourceFrameInContainer content.view.layer.opacity = 0 @@ -77,6 +85,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated let animator = UIViewPropertyAnimator(duration: duration, timingParameters: spring) animator.addAnimations { + dimmingView.layer.opacity = 1 + to.view.layer.opacity = 1 content.view.frame = destFrameInContainer @@ -90,6 +100,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated } animator.addCompletion { _ in + to.view.backgroundColor = .black + if sourceToDestTransform != nil { self.sourceView.transform = origSourceTransform }