Load progress indicator
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user