Load progress indicator

This commit is contained in:
James Magahern
2020-07-28 11:31:30 -07:00
parent 37eeeacc85
commit 5e80faac62
2 changed files with 68 additions and 4 deletions

View File

@@ -19,6 +19,8 @@ class BrowserViewController: UIViewController,
private var blockedScriptOrigins = Set<String>()
override var canBecomeFirstResponder: Bool { true }
private var loadingObservation: NSKeyValueObservation?
init() {
super.init(nibName: nil, bundle: nil)
}
@@ -53,6 +55,11 @@ class BrowserViewController: UIViewController,
// TextField delegate
toolbarController.urlBar.textField.delegate = self
// Load progress
loadingObservation = webView.observe(\.estimatedProgress) { (webView, observedChange) in
self.toolbarController.urlBar.loadProgress = .loading(progress: webView.estimatedProgress)
}
self.view = browserView
}
@@ -94,6 +101,10 @@ class BrowserViewController: UIViewController,
}
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
toolbarController.urlBar.loadProgress = .complete
}
// MARK: UITextField Delegate
func textFieldShouldReturn(_ textField: UITextField) -> Bool {