Started working on history tracking
This commit is contained in:
@@ -273,14 +273,20 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
|
||||
updateTitleAndURL(forWebView: webView)
|
||||
|
||||
// Start requesting favicon
|
||||
if let url = webView.url {
|
||||
// Start requesting favicon
|
||||
tab.updateFaviconForURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
||||
toolbarController.urlBar.loadProgress = .complete
|
||||
|
||||
// Update history
|
||||
if let url = webView.url {
|
||||
let title = webView.title ?? ""
|
||||
BrowserHistory.shared.didNavigate(toURL: url, title: title)
|
||||
}
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, preferences: WKWebpagePreferences, decisionHandler: @escaping (WKNavigationActionPolicy, WKWebpagePreferences) -> Void)
|
||||
@@ -305,6 +311,15 @@ class BrowserViewController: UIViewController, WKNavigationDelegate,
|
||||
|
||||
// MARK: UITextField Delegate
|
||||
|
||||
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
if let text = textField.text {
|
||||
let matches = BrowserHistory.shared.visitedToplevelHistoryItems(matching: text)
|
||||
print(matches)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
if let text = textField.text?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user