Don't show error if url bar is first responder

This commit is contained in:
James Magahern
2020-07-31 18:33:04 -07:00
parent 29c416374f
commit 084fe0f286
2 changed files with 5 additions and 3 deletions

View File

@@ -144,6 +144,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
// Error button
toolbarController.urlBar.errorButton.addAction(UIAction(handler: { [unowned self] _ in
let alert = UIAlertController(title: "Error", message: self.loadError?.localizedDescription, preferredStyle: .actionSheet)
alert.popoverPresentationController?.sourceView = self.toolbarController.urlBar.errorButton
alert.addAction(UIAlertAction(title: "Reload", style: .destructive, handler: { _ in
self.webView.reload()

View File

@@ -157,10 +157,8 @@ class URLBar: UIView
blinkAnimation.duration = 1.0
blinkAnimation.repeatCount = .infinity
self.errorButton.isHidden = false
self.errorButton.layer.add(blinkAnimation, forKey: animationKey)
} else {
self.errorButton.isHidden = true
self.errorButton.layer.removeAnimation(forKey: animationKey)
}
}
@@ -178,7 +176,8 @@ class URLBar: UIView
refreshButton.frame = CGRect(origin: CGPoint(x: bounds.width - refreshButtonSize.width, y: 0), size: refreshButtonSize)
// Error button
if case .error(error: _) = loadProgress {
if case .error(error: _) = loadProgress, !textField.isFirstResponder {
errorButton.isHidden = false
errorButton.sizeToFit()
errorButton.frame = CGRect(
x: refreshButton.frame.minX - errorButton.frame.width - 8.0,
@@ -188,6 +187,8 @@ class URLBar: UIView
)
errorButton.frame = errorButton.frame.centeredY(inRect: bounds)
fadeCutoffLocation = (errorButton.frame.minX / bounds.width) - 0.1
} else {
errorButton.isHidden = true
}
// Fade mask