From 263210ac3c156a965a8cb1cddf882445e9a227be Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 9 Sep 2024 19:39:30 -0400 Subject: [PATCH] Fix gallery controls insets on iPhone 16 And change the default to the dynamic island metrics, so I hopefully don't have to touch this every year --- .../GalleryVC/GalleryItemViewController.swift | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift index 4a0369cb..b41f7397 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryItemViewController.swift @@ -378,9 +378,6 @@ 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 ] - let islandDeviceTopInsets: [CGFloat] = [ - 59, // iPhone 14 Pro, 14 Pro Max, 15 Pro, 15 Pro Max - ] if notchedDeviceTopInsets.contains(view.safeAreaInsets.top) { // the notch width is not the same for the iPhones 13, // but what we actually want is the same offset from the edges @@ -390,16 +387,18 @@ class GalleryItemViewController: UIViewController { let offset = (earWidth - (shareButton.imageView?.bounds.width ?? 0)) / 2 shareButtonLeadingConstraint.constant = offset closeButtonTrailingConstraint.constant = offset - } else if islandDeviceTopInsets.contains(view.safeAreaInsets.top) { - shareButtonLeadingConstraint.constant = 24 - shareButtonTopConstraint.constant = 24 - closeButtonTrailingConstraint.constant = 24 - closeButtonTopConstraint.constant = 24 - } else { + } else if view.safeAreaInsets.top == 0 { + // square corner devices shareButtonLeadingConstraint.constant = 8 shareButtonTopConstraint.constant = 8 closeButtonTrailingConstraint.constant = 8 closeButtonTopConstraint.constant = 8 + } else { + // dynamic island devices + shareButtonLeadingConstraint.constant = 24 + shareButtonTopConstraint.constant = 24 + closeButtonTrailingConstraint.constant = 24 + closeButtonTopConstraint.constant = 24 } }