From 24965df377b043d0c731a12337d2434d363e7fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=C2=A0Buczek?= Date: Wed, 23 Oct 2019 00:11:48 +0200 Subject: [PATCH] Bvc/toolbars --- .../Browser/BrowserViewController.swift | 40 +++++++++---------- .../Toolbars/UrlBar/TopToolbarView.swift | 27 +++++++------ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/Client/Frontend/Browser/BrowserViewController.swift b/Client/Frontend/Browser/BrowserViewController.swift index 9a36c622a92..e7a28b5c2d1 100644 --- a/Client/Frontend/Browser/BrowserViewController.swift +++ b/Client/Frontend/Browser/BrowserViewController.swift @@ -465,6 +465,7 @@ class BrowserViewController: UIViewController { header = UIStackView().then { $0.axis = .vertical $0.clipsToBounds = true + $0.translatesAutoresizingMaskIntoConstraints = false } header.addArrangedSubview(topToolbar) @@ -503,6 +504,7 @@ class BrowserViewController: UIViewController { view.addSubview(alertStackView) footer = UIView() + footer.translatesAutoresizingMaskIntoConstraints = false view.addSubview(footer) alertStackView.axis = .vertical alertStackView.alignment = .center @@ -599,6 +601,17 @@ class BrowserViewController: UIViewController { webViewContainerBackdrop.snp.makeConstraints { make in make.edges.equalTo(webViewContainer) } + + topTouchArea.snp.makeConstraints { make in + make.top.left.right.equalTo(self.view) + make.height.equalTo(BrowserViewControllerUX.ShowHeaderTapAreaHeight) + } + + readerModeBar?.snp.makeConstraints { make in + make.top.equalTo(self.header.snp.bottom) + make.height.equalTo(UIConstants.ToolbarHeight) + make.leading.trailing.equalTo(self.view) + } } override func viewDidLayoutSubviews() { @@ -842,19 +855,6 @@ class BrowserViewController: UIViewController { } override func updateViewConstraints() { - super.updateViewConstraints() - - topTouchArea.snp.remakeConstraints { make in - make.top.left.right.equalTo(self.view) - make.height.equalTo(BrowserViewControllerUX.ShowHeaderTapAreaHeight) - } - - readerModeBar?.snp.remakeConstraints { make in - make.top.equalTo(self.header.snp.bottom) - make.height.equalTo(UIConstants.ToolbarHeight) - make.leading.trailing.equalTo(self.view) - } - webViewContainer.snp.remakeConstraints { make in make.left.right.equalTo(self.view) @@ -871,13 +871,6 @@ class BrowserViewController: UIViewController { make.height.equalTo(height) } - // Setup the bottom toolbar - toolbar?.snp.remakeConstraints { make in - make.edges.equalTo(self.footer) - } - - topToolbar.setNeedsUpdateConstraints() - // Remake constraints even if we're already showing the home controller. // The home controller may change sizes if we tap the URL bar while on about:home. favoritesViewController?.view.snp.remakeConstraints { make in @@ -897,6 +890,13 @@ class BrowserViewController: UIViewController { make.bottom.equalTo(self.footer.snp.top) } } + + // Setup the bottom toolbar + toolbar?.snp.remakeConstraints { make in + make.edges.equalTo(self.footer) + } + + super.updateViewConstraints() } fileprivate func showHomePanelController(inline: Bool) { diff --git a/Client/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift b/Client/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift index 34562124250..ae72ece1563 100644 --- a/Client/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift +++ b/Client/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift @@ -203,15 +203,7 @@ class TopToolbarView: UIView, ToolbarProtocol { addSubview(mainStackView) helper = ToolbarHelper(toolbar: self) - setupConstraints() - - Preferences.General.showBookmarkToolbarShortcut.observe(from: self) - // Make sure we hide any views that shouldn't be showing in non-overlay mode. - updateViewsForOverlayModeAndToolbarChanges() - } - - private func setupConstraints() { // Buttons won't take unnecessary space and won't shrink actionButtons.forEach { $0.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) @@ -221,10 +213,6 @@ class TopToolbarView: UIView, ToolbarProtocol { // Url bar will expand while keeping space for other items on the address bar. locationContainer.setContentHuggingPriority(.defaultLow, for: .horizontal) - locationContainer.snp.makeConstraints { - $0.height.equalTo(TopToolbarViewUX.LocationHeight) - } - navigationStackView.addArrangedSubview(backButton) navigationStackView.addArrangedSubview(forwardButton) @@ -238,7 +226,20 @@ class TopToolbarView: UIView, ToolbarProtocol { mainStackView.setCustomSpacing(16, after: locationContainer) - mainStackView.snp.makeConstraints { make in + setupConstraints() + + Preferences.General.showBookmarkToolbarShortcut.observe(from: self) + + // Make sure we hide any views that shouldn't be showing in non-overlay mode. + updateViewsForOverlayModeAndToolbarChanges() + } + + private func setupConstraints() { + locationContainer.snp.remakeConstraints { + $0.height.equalTo(TopToolbarViewUX.LocationHeight) + } + + mainStackView.snp.remakeConstraints { make in make.top.bottom.equalTo(self) make.leading.equalTo(self.safeArea.leading).inset(topToolbarPadding) make.trailing.equalTo(self.safeArea.trailing).inset(topToolbarPadding)