Skip to content

Commit

Permalink
Hide bottom URL bar when find in page is active (#2339)
Browse files Browse the repository at this point in the history
  • Loading branch information
dus7 authored Jan 15, 2024
1 parent 0eb447c commit 6ad3a78
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions DuckDuckGo/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,29 @@ class MainViewCoordinator {
addressBarPosition = position
}

func hideNavigationBarWithBottomPosition() {
guard addressBarPosition.isBottom else {
return
}

// Hiding the container won't suffice as it still defines the contentContainer.bottomY through constraints
navigationBarContainer.isHidden = true

constraints.contentContainerBottomToNavigationBarContainerTop.isActive = false
constraints.contentContainerBottomToToolbarTop.isActive = true
}

func showNavigationBarWithBottomPosition() {
guard addressBarPosition.isBottom else {
return
}

constraints.contentContainerBottomToToolbarTop.isActive = false
constraints.contentContainerBottomToNavigationBarContainerTop.isActive = true

navigationBarContainer.isHidden = false
}

func setAddressBarTopActive(_ active: Bool) {
constraints.contentContainerBottomToToolbarTop.isActive = active
constraints.navigationBarContainerTop.isActive = active
Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,9 @@ extension MainViewController: FindInPageViewDelegate {
func done(findInPageView: FindInPageView) {
currentTab?.findInPage = nil
viewCoordinator.toolbar.accessibilityElementsHidden = false

viewCoordinator.showNavigationBarWithBottomPosition()
}

}

extension MainViewController: BrowserChromeDelegate {
Expand Down Expand Up @@ -1801,6 +1802,8 @@ extension MainViewController: TabDelegate {
func tabDidRequestFindInPage(tab: TabViewController) {
updateFindInPage()
_ = findInPageView?.becomeFirstResponder()

viewCoordinator.hideNavigationBarWithBottomPosition()
}

func closeFindInPage(tab: TabViewController) {
Expand Down

0 comments on commit 6ad3a78

Please sign in to comment.