History UI improvements
This commit is contained in:
@@ -470,13 +470,34 @@ class BrowserViewController: UIViewController
|
||||
}
|
||||
|
||||
internal func showHistoryWindow() {
|
||||
let historyViewController = HistoryBrowserViewController()
|
||||
let historyViewController = HistoryBrowserViewController { [unowned self] url in
|
||||
if tab.url == nil {
|
||||
tab.beginLoadingURL(url)
|
||||
} else {
|
||||
createNewTab(withURL: url)
|
||||
}
|
||||
|
||||
presentedViewController?.dismiss(animated: true)
|
||||
}
|
||||
|
||||
historyViewController.title = "History"
|
||||
historyViewController.navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .done, primaryAction: UIAction { _ in
|
||||
// xxx: This is not the SwiftUI-y way to do this.
|
||||
historyViewController.dismiss(animated: true)
|
||||
})
|
||||
|
||||
historyViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Clear", primaryAction: UIAction { [unowned self] action in
|
||||
let alertController = UIAlertController(title: "Clear History", message: "Are you sure you want to clear all history?", preferredStyle: .actionSheet)
|
||||
alertController.addAction(UIAlertAction(title: "Clear", style: .destructive, handler: { [unowned self] _ in
|
||||
BrowserHistory.shared.clearAllHistory()
|
||||
presentedViewController?.dismiss(animated: true)
|
||||
}))
|
||||
alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel))
|
||||
alertController.popoverPresentationController?.sourceItem = action.presentationSourceItem
|
||||
|
||||
presentedViewController?.present(alertController, animated: true)
|
||||
})
|
||||
|
||||
let navigationController = UINavigationController(rootViewController: historyViewController)
|
||||
present(navigationController, animated: true)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user