Adds history browser view

This commit is contained in:
James Magahern
2023-01-20 17:28:15 -08:00
parent f374f3ebe8
commit 53efb5389e
9 changed files with 177 additions and 2 deletions

View File

@@ -156,6 +156,10 @@ extension BrowserViewController: ShortcutResponder
showSettingsWindow()
}
func showHistory(_ sender: Any?) {
showHistoryWindow()
}
func toggleDarkMode(_ sender: Any?) {
self.darkModeEnabled = !self.darkModeEnabled
}
@@ -163,4 +167,14 @@ extension BrowserViewController: ShortcutResponder
func openInReaderMode(_ sender: Any?) {
showReaderWindow()
}
func handleOpenURL(_ sender: Any?, url: URL?) {
guard let url else { return }
if tab.url == nil {
tab.beginLoadingURL(url)
} else {
createNewTab(withURL: url)
}
}
}

View File

@@ -333,6 +333,12 @@ class BrowserViewController: UIViewController
showShareSheetForCurrentURL(fromViewController: documentControls)
}, for: .touchUpInside)
// History
documentControls.historyView.addAction(UIAction { [unowned self] action in
documentControls.dismiss(animated: false, completion: nil)
showHistory(action)
}, for: .touchUpInside)
present(documentControls, animated: true, completion: nil)
}), for: .touchUpInside)
@@ -463,6 +469,17 @@ class BrowserViewController: UIViewController
}
}
internal func showHistoryWindow() {
let historyViewController = HistoryBrowserViewController()
historyViewController.title = "History"
historyViewController.navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .done, primaryAction: UIAction { _ in
historyViewController.dismiss(animated: true)
})
let navigationController = UINavigationController(rootViewController: historyViewController)
present(navigationController, animated: true)
}
internal func updateLoadProgress(forWebView webView: WKWebView) {
if let loadError = tab.loadError {
toolbarController.urlBar.loadProgress = .error(error: loadError)