Don't show error if url bar is first responder
This commit is contained in:
@@ -144,6 +144,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
|||||||
// Error button
|
// Error button
|
||||||
toolbarController.urlBar.errorButton.addAction(UIAction(handler: { [unowned self] _ in
|
toolbarController.urlBar.errorButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||||
let alert = UIAlertController(title: "Error", message: self.loadError?.localizedDescription, preferredStyle: .actionSheet)
|
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
|
alert.addAction(UIAlertAction(title: "Reload", style: .destructive, handler: { _ in
|
||||||
self.webView.reload()
|
self.webView.reload()
|
||||||
|
|||||||
@@ -157,10 +157,8 @@ class URLBar: UIView
|
|||||||
blinkAnimation.duration = 1.0
|
blinkAnimation.duration = 1.0
|
||||||
blinkAnimation.repeatCount = .infinity
|
blinkAnimation.repeatCount = .infinity
|
||||||
|
|
||||||
self.errorButton.isHidden = false
|
|
||||||
self.errorButton.layer.add(blinkAnimation, forKey: animationKey)
|
self.errorButton.layer.add(blinkAnimation, forKey: animationKey)
|
||||||
} else {
|
} else {
|
||||||
self.errorButton.isHidden = true
|
|
||||||
self.errorButton.layer.removeAnimation(forKey: animationKey)
|
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)
|
refreshButton.frame = CGRect(origin: CGPoint(x: bounds.width - refreshButtonSize.width, y: 0), size: refreshButtonSize)
|
||||||
|
|
||||||
// Error button
|
// Error button
|
||||||
if case .error(error: _) = loadProgress {
|
if case .error(error: _) = loadProgress, !textField.isFirstResponder {
|
||||||
|
errorButton.isHidden = false
|
||||||
errorButton.sizeToFit()
|
errorButton.sizeToFit()
|
||||||
errorButton.frame = CGRect(
|
errorButton.frame = CGRect(
|
||||||
x: refreshButton.frame.minX - errorButton.frame.width - 8.0,
|
x: refreshButton.frame.minX - errorButton.frame.width - 8.0,
|
||||||
@@ -188,6 +187,8 @@ class URLBar: UIView
|
|||||||
)
|
)
|
||||||
errorButton.frame = errorButton.frame.centeredY(inRect: bounds)
|
errorButton.frame = errorButton.frame.centeredY(inRect: bounds)
|
||||||
fadeCutoffLocation = (errorButton.frame.minX / bounds.width) - 0.1
|
fadeCutoffLocation = (errorButton.frame.minX / bounds.width) - 0.1
|
||||||
|
} else {
|
||||||
|
errorButton.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fade mask
|
// Fade mask
|
||||||
|
|||||||
Reference in New Issue
Block a user