Feature: Adds open in background (Shift+Cmd)

This commit is contained in:
James Magahern
2022-02-21 16:01:01 -08:00
parent 224a39b64f
commit f32c246e35
6 changed files with 86 additions and 32 deletions

View File

@@ -78,8 +78,7 @@ extension BrowserViewController: WKNavigationDelegate, WKUIDelegate
decisionHandler(.cancel, preferences)
// Start navigation in a new tab
let tab = tabController.createNewTab(url: navigationAction.request.url)
self.tab = tab
createNewTab(withURL: navigationAction.request.url, loadInBackground: self.shiftKeyHeld)
// Reset this flag.
commandKeyHeld = false
@@ -140,16 +139,23 @@ extension BrowserViewController: WKNavigationDelegate, WKUIDelegate
discoverabilityTitle: nil,
attributes: [],
state: .off) { [unowned self] _ in
let newTab = tabController.createNewTab(url: elementInfo.linkURL)
self.tab = newTab
self.createNewTab(withURL: elementInfo.linkURL, loadInBackground: false)
}
let openInBackground = UIAction(title: "Open in Background",
image: UIImage(systemName: "plus.rectangle.on.rectangle"),
identifier: nil,
discoverabilityTitle: nil,
attributes: [],
state: .off) { [unowned self] _ in
self.createNewTab(withURL: elementInfo.linkURL, loadInBackground: true)
}
return UIMenu(title: elementInfo.linkURL?.absoluteString ?? "Link",
image: nil,
identifier: nil,
options: .displayInline,
children: [ openInNewTab ] + menuElements)
children: [ openInNewTab, openInBackground ] + menuElements)
}
completionHandler(menuConfig)