From 4ea61542a035c520052d2c49910efaede17adbba Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 26 Dec 2024 17:25:31 -0500 Subject: [PATCH] Fix gallery buttons changing position during dismiss animation Closes #554 --- .../Sources/GalleryVC/GalleryItemViewController.swift | 4 ++++ .../GalleryVC/Sources/GalleryVC/GalleryViewController.swift | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift index 3c5df912..ba2c6eec 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift @@ -11,6 +11,7 @@ import AVFoundation @MainActor protocol GalleryItemViewControllerDelegate: AnyObject { func isGalleryBeingPresented() -> Bool + func isGalleryBeingDismissed() -> Bool func addPresentationAnimationCompletion(_ block: @escaping () -> Void) func galleryItemClose(_ item: GalleryItemViewController) func galleryItemApplicationActivities(_ item: GalleryItemViewController) -> [UIActivity]? @@ -376,6 +377,9 @@ class GalleryItemViewController: UIViewController { } private func updateTopControlsInsets() { + guard delegate?.isGalleryBeingDismissed() != true else { + return + } let notchedDeviceTopInsets: [CGFloat] = [ 44, // iPhone X, Xs, Xs Max, 11 Pro, 11 Pro Max 48, // iPhone XR, 11 diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift index 8013c3fa..d9381ebf 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift @@ -139,6 +139,10 @@ extension GalleryViewController: GalleryItemViewControllerDelegate { isBeingPresented } + func isGalleryBeingDismissed() -> Bool { + isBeingDismissed + } + func addPresentationAnimationCompletion(_ block: @escaping () -> Void) { presentationAnimationCompletionHandlers.append(block) }