Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Bvc/toolbars
Browse files Browse the repository at this point in the history
  • Loading branch information
iccub committed Oct 28, 2019
1 parent f309402 commit 24965df
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
40 changes: 20 additions & 20 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ class BrowserViewController: UIViewController {
header = UIStackView().then {
$0.axis = .vertical
$0.clipsToBounds = true
$0.translatesAutoresizingMaskIntoConstraints = false
}
header.addArrangedSubview(topToolbar)

Expand Down Expand Up @@ -503,6 +504,7 @@ class BrowserViewController: UIViewController {

view.addSubview(alertStackView)
footer = UIView()
footer.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(footer)
alertStackView.axis = .vertical
alertStackView.alignment = .center
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand All @@ -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) {
Expand Down
27 changes: 14 additions & 13 deletions Client/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit 24965df

Please sign in to comment.