From 0eaacfd352eca168b53761d2831ee194112de9f7 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 22 Jan 2020 10:10:16 +1100 Subject: [PATCH] Fix layout issue on iPhone X / iOS 12 --- Signal/src/Loki/View Controllers/JoinPublicChatVC.swift | 4 ++-- Signal/src/Loki/View Controllers/LinkDeviceVC.swift | 6 +++--- Signal/src/Loki/View Controllers/NewPrivateChatVC.swift | 4 ++-- Signal/src/Loki/View Controllers/QRCodeVC.swift | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift b/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift index 92c8056e7..600ba4b5b 100644 --- a/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift +++ b/Signal/src/Loki/View Controllers/JoinPublicChatVC.swift @@ -94,7 +94,7 @@ final class JoinPublicChatVC : UIViewController, UIPageViewControllerDataSource, if #available(iOS 13, *) { height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight } else { - let statusBarHeight: CGFloat = 20 + let statusBarHeight = UIApplication.shared.statusBarFrame.height height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight - statusBarHeight } pageVCView.set(.height, to: height) @@ -208,7 +208,7 @@ private final class EnterChatURLVC : UIViewController { let stackView = UIStackView(arrangedSubviews: [ chatURLTextField, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, UIView.vStretchingSpacer(), nextButtonContainer ]) stackView.axis = .vertical stackView.alignment = .fill - stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.mediumSpacing, right: Values.largeSpacing) + stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing) stackView.isLayoutMarginsRelativeArrangement = true view.addSubview(stackView) stackView.pin(.leading, to: .leading, of: view) diff --git a/Signal/src/Loki/View Controllers/LinkDeviceVC.swift b/Signal/src/Loki/View Controllers/LinkDeviceVC.swift index 24d44e313..4b1cb7b6c 100644 --- a/Signal/src/Loki/View Controllers/LinkDeviceVC.swift +++ b/Signal/src/Loki/View Controllers/LinkDeviceVC.swift @@ -94,7 +94,7 @@ final class LinkDeviceVC : UIViewController, UIPageViewControllerDataSource, UIP if #available(iOS 13, *) { height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight } else { - let statusBarHeight: CGFloat = 20 + let statusBarHeight = UIApplication.shared.statusBarFrame.height height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight - statusBarHeight } pageVCView.set(.height, to: height) @@ -180,7 +180,7 @@ private final class EnterPublicKeyVC : UIViewController { linkButton.pin(.leading, to: .leading, of: linkButtonContainer, withInset: isSmallScreen ? 48 : 80) linkButton.pin(.top, to: .top, of: linkButtonContainer) linkButtonContainer.pin(.trailing, to: .trailing, of: linkButton, withInset: isSmallScreen ? 48 : 80) - linkButtonBottomConstraint = linkButtonContainer.pin(.bottom, to: .bottom, of: linkButton, withInset: Values.veryLargeSpacing) + linkButtonBottomConstraint = linkButtonContainer.pin(.bottom, to: .bottom, of: linkButton, withInset: Values.largeSpacing) // Set up top stack view let topStackView = UIStackView(arrangedSubviews: [ titleLabel, explanationLabel, publicKeyTextField ]) topStackView.axis = .vertical @@ -236,7 +236,7 @@ private final class EnterPublicKeyVC : UIViewController { @objc private func handleKeyboardWillHideNotification(_ notification: Notification) { bottomConstraint.constant = 0 - linkButtonBottomConstraint.constant = Values.veryLargeSpacing + linkButtonBottomConstraint.constant = Values.largeSpacing UIView.animate(withDuration: 0.25) { self.view.layoutIfNeeded() } diff --git a/Signal/src/Loki/View Controllers/NewPrivateChatVC.swift b/Signal/src/Loki/View Controllers/NewPrivateChatVC.swift index 1aab07880..75183021e 100644 --- a/Signal/src/Loki/View Controllers/NewPrivateChatVC.swift +++ b/Signal/src/Loki/View Controllers/NewPrivateChatVC.swift @@ -93,7 +93,7 @@ final class NewPrivateChatVC : UIViewController, UIPageViewControllerDataSource, if #available(iOS 13, *) { height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight } else { - let statusBarHeight: CGFloat = 20 + let statusBarHeight = UIApplication.shared.statusBarFrame.height height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight - statusBarHeight } pageVCView.set(.height, to: height) @@ -217,7 +217,7 @@ private final class EnterPublicKeyVC : UIViewController { let stackView = UIStackView(arrangedSubviews: [ publicKeyTextField, UIView.spacer(withHeight: Values.smallSpacing), explanationLabel, UIView.spacer(withHeight: Values.largeSpacing), separator, UIView.spacer(withHeight: Values.veryLargeSpacing), userPublicKeyLabel, UIView.spacer(withHeight: Values.veryLargeSpacing), buttonContainer, UIView.vStretchingSpacer(), nextButtonContainer ]) stackView.axis = .vertical stackView.alignment = .fill - stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.mediumSpacing, right: Values.largeSpacing) + stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing) stackView.isLayoutMarginsRelativeArrangement = true view.addSubview(stackView) stackView.pin(to: view) diff --git a/Signal/src/Loki/View Controllers/QRCodeVC.swift b/Signal/src/Loki/View Controllers/QRCodeVC.swift index 6372156b7..89d8c38c9 100644 --- a/Signal/src/Loki/View Controllers/QRCodeVC.swift +++ b/Signal/src/Loki/View Controllers/QRCodeVC.swift @@ -84,7 +84,7 @@ final class QRCodeVC : UIViewController, UIPageViewControllerDataSource, UIPageV if #available(iOS 13, *) { height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight } else { - let statusBarHeight: CGFloat = 20 + let statusBarHeight = UIApplication.shared.statusBarFrame.height height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight - statusBarHeight } pageVCView.set(.height, to: height) @@ -211,7 +211,7 @@ private final class ViewMyQRCodeVC : UIViewController { stackView.axis = .vertical stackView.spacing = isSmallScreen ? Values.mediumSpacing : Values.largeSpacing stackView.alignment = .fill - stackView.layoutMargins = UIEdgeInsets(top: Values.mediumSpacing, left: Values.largeSpacing, bottom: Values.mediumSpacing, right: Values.largeSpacing) + stackView.layoutMargins = UIEdgeInsets(top: Values.largeSpacing, left: Values.largeSpacing, bottom: Values.largeSpacing, right: Values.largeSpacing) stackView.isLayoutMarginsRelativeArrangement = true view.addSubview(stackView) stackView.pin(.leading, to: .leading, of: view)