From 666d2c468a6804f2e4d67ca64d0983bf715f3b03 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 26 Dec 2024 17:25:49 -0500 Subject: [PATCH] Fix gallery controls being positioned incorrectly in landscape --- .../GalleryVC/GalleryItemViewController.swift | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift index ba2c6eec..5b93ebe4 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift @@ -386,7 +386,18 @@ class GalleryItemViewController: UIViewController { 47, // iPhone 12, 12 Pro, 12 Pro Max, 13, 13 Pro, 13 Pro Max, 14, 14 Plus 50, // iPhone 12 mini, 13 mini ] - if notchedDeviceTopInsets.contains(view.safeAreaInsets.top) { + let topInset: CGFloat + switch view.window?.windowScene?.interfaceOrientation { + case .portraitUpsideDown: + topInset = view.safeAreaInsets.bottom + case .landscapeLeft: + topInset = view.safeAreaInsets.right + case .landscapeRight: + topInset = view.safeAreaInsets.left + default: + topInset = view.safeAreaInsets.top + } + if notchedDeviceTopInsets.contains(topInset) { // the notch width is not the same for the iPhones 13, // but what we actually want is the same offset from the edges // since the corner radius didn't change @@ -395,7 +406,7 @@ class GalleryItemViewController: UIViewController { let offset = (earWidth - (shareButton.imageView?.bounds.width ?? 0)) / 2 shareButtonLeadingConstraint.constant = offset closeButtonTrailingConstraint.constant = offset - } else if view.safeAreaInsets.top == 0 { + } else if topInset == 0 { // square corner devices shareButtonLeadingConstraint.constant = 8 shareButtonTopConstraint.constant = 8