Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Add context menu to be on par with Safari.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Jul 17, 2023
1 parent 8959173 commit d79a5bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sources/Brave/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,10 @@ extension BrowserViewController: TabsBarViewControllerDelegate {
break
}
}

func tabsBarDidSelectAddNewWindow(_ isPrivate: Bool) {
self.openInNewWindow(url: nil, isPrivate: isPrivate)
}
}

extension BrowserViewController: TabDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protocol TabsBarViewControllerDelegate: AnyObject {
func tabsBarDidLongPressAddTab(_ tabsBarController: TabsBarViewController, button: UIButton)
func tabsBarDidSelectAddNewTab(_ isPrivate: Bool)
func tabsBarDidChangeReaderModeVisibility(_ isHidden: Bool)

func tabsBarDidSelectAddNewWindow(_ isPrivate: Bool)
}

class TabsBarViewController: UIViewController {
Expand Down Expand Up @@ -123,6 +123,14 @@ class TabsBarViewController: UIViewController {
})

newTabMenu.append(openNewTab)

newTabMenu.append(UIAction(title: Strings.newWindowTitle, image: UIImage(braveSystemNamed: "leo.window"), handler: UIAction.deferredActionHandler { [unowned self] _ in
self.delegate?.tabsBarDidSelectAddNewWindow(false)
}))

newTabMenu.append(UIAction(title: Strings.newPrivateWindowTitle, image: UIImage(braveSystemNamed: "leo.window.tab-private"), handler: UIAction.deferredActionHandler { [unowned self] _ in
self.delegate?.tabsBarDidSelectAddNewWindow(true)
}))

plusButton.menu = UIMenu(title: "", identifier: nil, children: newTabMenu)
privateModeCancellable = tabManager?.privateBrowsingManager
Expand Down
2 changes: 2 additions & 0 deletions Sources/BraveStrings/BraveStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ extension Strings {
comment: "Error description when there is an error while navigating to Files App")
public static let openInNewWindowTitle = NSLocalizedString("OpenInNewWindowTitle", tableName: "BraveShared", bundle: .module, value: "Open in New Window", comment: "Context menu item for opening a link in a new window")
public static let openInNewPrivateWindowTitle = NSLocalizedString("OpenInNewPrivateWindowTitle", tableName: "BraveShared", bundle: .module, value: "Open in New Private Window", comment: "Context menu item for opening a link in a new private browsing window")
public static let newWindowTitle = NSLocalizedString("NewWindowTitle", tableName: "BraveShared", bundle: .module, value: "New Window", comment: "Context menu item for opening a new window")
public static let newPrivateWindowTitle = NSLocalizedString("NewPrivateWindowTitle", tableName: "BraveShared", bundle: .module, value: "New Private Window", comment: "Context menu item for opening a new private browsing window")
}

// MARK:- DefaultBrowserIntroCalloutViewController.swift
Expand Down

0 comments on commit d79a5bd

Please sign in to comment.