TabView: Favicons in tab bar
This commit is contained in:
@@ -35,6 +35,7 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
private var backButtonObservation: NSKeyValueObservation?
|
||||
private var forwardButtonObservation: NSKeyValueObservation?
|
||||
private var activeTabObservation: AnyCancellable?
|
||||
private var faviconObservation: AnyCancellable?
|
||||
|
||||
private var loadError: Error?
|
||||
|
||||
@@ -276,12 +277,14 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
}
|
||||
|
||||
private func updateTitleAndURL(forWebView webView: WKWebView) {
|
||||
browserView.titlebarView.setTitle(webView.title ?? "")
|
||||
|
||||
if let urlString = webView.url?.absoluteString {
|
||||
toolbarController.urlBar.textField.text = urlString
|
||||
} else {
|
||||
toolbarController.urlBar.textField.text = ""
|
||||
if webView == browserView.webView {
|
||||
browserView.titlebarView.setTitle(webView.title ?? "")
|
||||
|
||||
if let urlString = webView.url?.absoluteString {
|
||||
toolbarController.urlBar.textField.text = urlString
|
||||
} else {
|
||||
toolbarController.urlBar.textField.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out which tab this corresponds to
|
||||
@@ -336,6 +339,12 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
toolbarController.forwardButton.isEnabled = webView.canGoForward
|
||||
})
|
||||
|
||||
// Favicon observation
|
||||
faviconObservation = tab.$favicon.receive(on: DispatchQueue.main)
|
||||
.sink { [unowned self] _ in
|
||||
updateTitleAndURL(forWebView: webView)
|
||||
}
|
||||
|
||||
// Script blocker button
|
||||
updateScriptBlockerButton()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user