From 95ae1dd927baa8db715d1de3bca8005c852f09cf Mon Sep 17 00:00:00 2001 From: Kyle Hickinson Date: Mon, 18 Sep 2023 15:19:22 -0400 Subject: [PATCH] Fix #8009: Update toolbar constraints to utilize safe area properly The value of `UIApplication.shared.keyWindow?.safeAreaInsets.bottom` is not updated when the `updateViewConstraints` method is called. However calculating this height manually is not correct/not needed, as we can simply rely on the safe area layout guides --- .../Brave/Frontend/Browser/BrowserViewController.swift | 2 -- .../Toolbars/BottomToolbar/BottomToolbarView.swift | 1 + Sources/Brave/Frontend/UIConstants.swift | 8 +------- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/BrowserViewController.swift b/Sources/Brave/Frontend/Browser/BrowserViewController.swift index 9794aa07649..b3dc145909f 100644 --- a/Sources/Brave/Frontend/Browser/BrowserViewController.swift +++ b/Sources/Brave/Frontend/Browser/BrowserViewController.swift @@ -1287,8 +1287,6 @@ public class BrowserViewController: UIViewController { footer.snp.remakeConstraints { make in make.bottom.equalTo(toolbarLayoutGuide) make.leading.trailing.equalTo(self.view) - let height = self.toolbar == nil ? 0 : UIConstants.bottomToolbarHeight - make.height.equalTo(height) } bottomBarKeyboardBackground.snp.remakeConstraints { diff --git a/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift b/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift index 60a8b12a9c5..c5b92ed9095 100644 --- a/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift +++ b/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/BottomToolbarView.swift @@ -99,6 +99,7 @@ class BottomToolbarView: UIView, ToolbarProtocol { contentView.snp.makeConstraints { make in make.leading.trailing.top.equalTo(self) make.bottom.equalTo(self.safeArea.bottom) + make.height.equalTo(UIConstants.toolbarHeight) } super.updateConstraints() } diff --git a/Sources/Brave/Frontend/UIConstants.swift b/Sources/Brave/Frontend/UIConstants.swift index 00155924a2a..af628626636 100644 --- a/Sources/Brave/Frontend/UIConstants.swift +++ b/Sources/Brave/Frontend/UIConstants.swift @@ -11,13 +11,7 @@ public struct UIConstants { static let defaultPadding: CGFloat = 10 static let snackbarButtonHeight: CGFloat = 48 static var toolbarHeight: CGFloat = 44 - static var bottomToolbarHeight: CGFloat { - get { - let bottomInset: CGFloat = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0.0 - return toolbarHeight + bottomInset - } - } - + // Static fonts static let defaultChromeSize: CGFloat = 16 static let defaultChromeSmallSize: CGFloat = 11