Change the full screen tap zone to be the center of the navigation bar instead of the whole navigation bar. Issue #1450.

This commit is contained in:
Maurice Parker 2019-12-26 12:21:56 -07:00
parent 84d1ccadfd
commit 00ed368683
2 changed files with 12 additions and 20 deletions

View File

@ -114,6 +114,14 @@ class ArticleViewController: UIViewController {
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange(_:)), name: UIContentSizeCategory.didChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(willEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
let fullScreenTapZone = UIView()
NSLayoutConstraint.activate([
fullScreenTapZone.widthAnchor.constraint(equalToConstant: 150),
fullScreenTapZone.heightAnchor.constraint(equalToConstant: 44)
])
fullScreenTapZone.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTapNavigationBar)))
navigationItem.titleView = fullScreenTapZone
articleExtractorButton.addTarget(self, action: #selector(toggleArticleExtractor(_:)), for: .touchUpInside)
toolbarItems?.insert(UIBarButtonItem(customView: articleExtractorButton), at: 6)
@ -275,6 +283,10 @@ class ArticleViewController: UIViewController {
// MARK: Actions
@objc func didTapNavigationBar() {
hideBars()
}
@objc func showBars(_ sender: Any) {
showBars()
}
@ -356,14 +368,6 @@ class ArticleViewController: UIViewController {
}
// MARK: InteractiveNavigationControllerTappable
extension ArticleViewController: InteractiveNavigationControllerTappable {
func didTapNavigationBar() {
hideBars()
}
}
// MARK: UIContextMenuInteractionDelegate
extension ArticleViewController: UIContextMenuInteractionDelegate {

View File

@ -8,10 +8,6 @@
import UIKit
protocol InteractiveNavigationControllerTappable {
func didTapNavigationBar()
}
class InteractiveNavigationController: UINavigationController {
private let poppableDelegate = PoppableGestureRecognizerDelegate()
@ -33,8 +29,6 @@ class InteractiveNavigationController: UINavigationController {
poppableDelegate.originalDelegate = interactivePopGestureRecognizer?.delegate
poppableDelegate.navigationController = self
interactivePopGestureRecognizer?.delegate = poppableDelegate
navigationBar.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(didTapNavigationBar)))
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
@ -44,13 +38,7 @@ class InteractiveNavigationController: UINavigationController {
}
}
@objc func didTapNavigationBar() {
if let tappable = topViewController as? InteractiveNavigationControllerTappable {
tappable.didTapNavigationBar()
}
}
}
// MARK: Private