Started working on history tracking

This commit is contained in:
James Magahern
2020-08-14 20:05:36 -07:00
parent c6adf599f4
commit c6a27b3fd9
5 changed files with 171 additions and 1 deletions

View File

@@ -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) {