From 8c7bebcce87b70d8be7db917282ad999d549fcaa Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 26 Jan 2020 18:26:58 -0500 Subject: [PATCH] Fix large image controls being positioned incorrectly on notched-devices when opening via a context menu preview. The constraints for the top controls were being set only once, but when showing a large image in the contxt menu preview window, the top inset safe area is 0 and didn't become 44 (the value for notched devices) until the preview was expanded. Fixes #86 --- .../LargeImageViewController.swift | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Tusker/Screens/Large Image/LargeImageViewController.swift b/Tusker/Screens/Large Image/LargeImageViewController.swift index 5658b1d5..45890c52 100644 --- a/Tusker/Screens/Large Image/LargeImageViewController.swift +++ b/Tusker/Screens/Large Image/LargeImageViewController.swift @@ -37,8 +37,6 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate { @IBOutlet weak var bottomControlsView: UIView! @IBOutlet weak var descriptionLabel: UILabel! - var initializedTopControlsConstrains = false - var image: UIImage? var gifData: Data? var imageDescription: String? @@ -120,16 +118,13 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate { centerImage() - if !initializedTopControlsConstrains { - initializedTopControlsConstrains = true - if view.safeAreaInsets.top == 44 { - // running on iPhone X style notched device - let notchWidth: CGFloat = 209 - let earWidth = (view.bounds.width - notchWidth) / 2 - let offset = (earWidth - shareButton.bounds.width) / 2 - shareButtonLeadingConstraint.constant = offset - closeButtonTrailingConstraint.constant = offset - } + if view.safeAreaInsets.top == 44 { + // running on iPhone X style notched device + let notchWidth: CGFloat = 209 + let earWidth = (view.bounds.width - notchWidth) / 2 + let offset = (earWidth - shareButton.bounds.width) / 2 + shareButtonLeadingConstraint.constant = offset + closeButtonTrailingConstraint.constant = offset } }