From 084fe0f286d082a563e1d15ee90366be5b68ec0f Mon Sep 17 00:00:00 2001 From: James Magahern Date: Fri, 31 Jul 2020 18:33:04 -0700 Subject: [PATCH] Don't show error if url bar is first responder --- App/Browser View/BrowserViewController.swift | 1 + App/Titlebar and URL Bar/URLBar.swift | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/App/Browser View/BrowserViewController.swift b/App/Browser View/BrowserViewController.swift index 609bd78..f49fee1 100644 --- a/App/Browser View/BrowserViewController.swift +++ b/App/Browser View/BrowserViewController.swift @@ -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() diff --git a/App/Titlebar and URL Bar/URLBar.swift b/App/Titlebar and URL Bar/URLBar.swift index 299aeba..4317ea4 100644 --- a/App/Titlebar and URL Bar/URLBar.swift +++ b/App/Titlebar and URL Bar/URLBar.swift @@ -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