Skip to content

Commit

Permalink
Fix showing bars on tapping bottom of the screen (#3684)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1206226850447395/1208832461871070/f
Tech Design URL:
CC:

**Description**:

Updated the way how "bottom of screen" is calculated. I think this was
broken for some time already but nobody noticed.
Changed to show the bars with animation.

**Steps to test this PR**:
1. Open a website which allows to scroll and hide the bars.
2. Try tapping on top/bottom to reveal bars.
3. Try with top and bottom bar setting.

**Definition of Done (Internal Only)**:

* [ ] Does this PR satisfy our [Definition of
Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?

**Copy Testing**:

* [ ] Use of correct apostrophes in new copy, ie `’` rather than `'`

**Orientation Testing**:

* [ ] Portrait
* [ ] Landscape

**Device Testing**:

* [ ] iPhone SE (1st Gen)
* [ ] iPhone 8
* [ ] iPhone X
* [ ] iPhone 14 Pro
* [ ] iPad

**OS Testing**:

* [ ] iOS 15
* [ ] iOS 16
* [ ] iOS 17

**Theme Testing**:

* [ ] Light theme
* [ ] Dark theme

---
###### Internal references:
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
  • Loading branch information
dus7 authored Dec 9, 2024
1 parent f565fd5 commit e110da8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ class TabViewController: UIViewController {
}

@IBAction func onBottomOfScreenTapped(_ sender: UITapGestureRecognizer) {
showBars(animated: false)
showBars()
}

private func showBars(animated: Bool = true) {
Expand Down Expand Up @@ -2476,13 +2476,15 @@ extension TabViewController: UIGestureRecognizerDelegate {
}

private func isShowBarsTap(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
let y = gestureRecognizer.location(in: webView).y
let y = gestureRecognizer.location(in: self.view).y
return gestureRecognizer == showBarsTapGestureRecogniser && chromeDelegate?.isToolbarHidden == true && isBottom(yPosition: y)
}

private func isBottom(yPosition y: CGFloat) -> Bool {
guard let chromeDelegate = chromeDelegate else { return false }
return y > (view.frame.size.height - chromeDelegate.toolbarHeight)
let webViewFrameInTabView = webView.convert(webView.bounds, to: view)
let bottomOfWebViewInTabView = webViewFrameInTabView.maxY - webView.scrollView.contentInset.bottom

return y > bottomOfWebViewInTabView
}

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherRecognizer: UIGestureRecognizer) -> Bool {
Expand Down

0 comments on commit e110da8

Please sign in to comment.