Long press on the window button to open a new tab

This commit is contained in:
James Magahern
2020-07-31 16:36:10 -07:00
parent 5457a05309
commit 030c1db45c
4 changed files with 41 additions and 0 deletions

View File

@@ -155,6 +155,7 @@ class ToolbarViewController: UIViewController
let windowButton = UIButton(frame: .zero)
let backButton = UIButton(frame: .zero)
let forwardButton = UIButton(frame: .zero)
let newTabButton = UIButton(frame: .zero)
var darkModeEnabled: Bool = false {
didSet {
@@ -189,6 +190,9 @@ class ToolbarViewController: UIViewController
// Forward button
forwardButton.setImage(UIImage(systemName: "chevron.right"), for: .normal)
// New tab button
newTabButton.setImage(UIImage(systemName: "plus"), for: .normal)
let toolbarAnimationDuration: TimeInterval = 0.3
urlBar.textField.addAction(.init(handler: { [traitCollection, toolbarView, urlBar] _ in
if traitCollection.horizontalSizeClass == .compact {
@@ -223,6 +227,7 @@ class ToolbarViewController: UIViewController
toolbarView.trailingButtonsView.addButtonView(darkModeButton)
toolbarView.trailingButtonsView.addButtonView(shareButton)
toolbarView.trailingButtonsView.addButtonView(scriptControllerIconView)
toolbarView.trailingButtonsView.addButtonView(newTabButton)
toolbarView.trailingButtonsView.addButtonView(windowButton)
}
}