Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify bookmarks context menu across different views #3138

Merged
merged 37 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
784dfbc
NSPopover-based Bookmarks menu system
mallexxx Aug 15, 2024
b6d82b0
fix button spacing constant usage
mallexxx Aug 15, 2024
6f8452a
fix clipped items indicator
mallexxx Aug 15, 2024
2558ca1
fixing Tests
mallexxx Aug 19, 2024
4530a52
Merge remote-tracking branch 'origin/main' into alex/bookmarks-bar/menu
mallexxx Aug 21, 2024
8217dc4
minor PR adjustment
mallexxx Aug 22, 2024
98ec34e
Roll back BookmarkListViewController, add BookmarksBarMenuViewController
mallexxx Aug 22, 2024
a65352c
Unify bookmarks context menu across different views
mallexxx Aug 22, 2024
03580e5
Add more tests, fix search items
mallexxx Aug 23, 2024
7e0b916
fix test
mallexxx Aug 23, 2024
e032961
Merge branch 'alex/bookmarks-context-menu' into alex/bookmarks-bar/menu
mallexxx Aug 23, 2024
152e514
cleanup
mallexxx Aug 23, 2024
a8c0520
Bookmarks bar/menu code adjustments (#3107)
mallexxx Aug 23, 2024
686b2df
Add Open All in new tabs item; Close all bookmarks popovers on select…
mallexxx Aug 23, 2024
376b969
Add Bookmarks menu drag&drop support (#3111)
mallexxx Aug 23, 2024
d54dd22
Bookmarks Menu keyboard controls (#3112)
mallexxx Aug 23, 2024
48e2f66
Update Bookmarks Menu size (#3113)
mallexxx Aug 23, 2024
e162f1a
Merge remote-tracking branch 'origin/main' into alex/bookmarks-contex…
mallexxx Aug 23, 2024
b790e32
Merge branch 'alex/bookmarks-context-menu' into alex/bookmarks-bar/menu
mallexxx Aug 23, 2024
791c3eb
fix missing disclosure indicators
mallexxx Aug 23, 2024
4fd4c67
fix MainActor warnings
mallexxx Aug 28, 2024
cc228c1
Fix Manage button selector; add Manage Bookmarks "…" menu item, Add M…
mallexxx Aug 28, 2024
02a99bc
fix tests
mallexxx Aug 28, 2024
bc2fec3
Merge remote-tracking branch 'origin/main' into alex/bookmarks-bar/menu
mallexxx Aug 28, 2024
e3a1c1c
Merge remote-tracking branch 'origin/main' into alex/bookmarks-contex…
mallexxx Aug 30, 2024
27d9364
Merge branch 'alex/bookmarks-bar/menu' into alex/bookmarks-context-menu
mallexxx Aug 30, 2024
85784d5
Remove Manage Bookmarks item from bookmark manager details context menu
mallexxx Aug 30, 2024
db4b4ab
Fix cells highlighting in different modes
mallexxx Aug 30, 2024
f06c808
Merge branch 'alex/bookmarks-bar/menu' into alex/bookmarks-context-menu
mallexxx Aug 30, 2024
8840635
Fix PR issues
mallexxx Aug 30, 2024
0089d26
fix tests
mallexxx Aug 30, 2024
04f3ee6
fix test
mallexxx Aug 30, 2024
aa46e5f
disable assertion for empty context menu for non-bookmark object
mallexxx Aug 30, 2024
f304159
disable Open All menu items for folders without bookmarks
mallexxx Aug 30, 2024
1730a6f
Fix bookmarks menu width calculation
mallexxx Aug 30, 2024
2120bfe
rollback Submodules/privacy-reference-tests
mallexxx Aug 30, 2024
36a070b
fix tests
mallexxx Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 41 additions & 29 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm.git",
"location" : "https://github.com/airbnb/lottie-spm",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 This should be reverted

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it shouldn‘t as it‘s without .git in Package.swift

"state" : {
"revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605",
"version" : "4.4.3"
Expand Down
11 changes: 5 additions & 6 deletions DuckDuckGo/Bookmarks/Model/BookmarkOutlineViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS

private let bookmarkManager: BookmarkManager
private let showMenuButtonOnHover: Bool
private let onMenuRequestedAction: ((BookmarkOutlineCellView) -> Void)?
private let presentFaviconsFetcherOnboarding: (() -> Void)?

private var favoritesPseudoFolder = PseudoFolder.favorites
Expand All @@ -53,14 +52,12 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS
treeController: BookmarkTreeController,
sortMode: BookmarksSortMode,
showMenuButtonOnHover: Bool = true,
onMenuRequestedAction: ((BookmarkOutlineCellView) -> Void)? = nil,
presentFaviconsFetcherOnboarding: (() -> Void)? = nil
) {
self.contentMode = contentMode
self.bookmarkManager = bookmarkManager
self.treeController = treeController
self.showMenuButtonOnHover = showMenuButtonOnHover
self.onMenuRequestedAction = onMenuRequestedAction
self.presentFaviconsFetcherOnboarding = presentFaviconsFetcherOnboarding

super.init()
Expand Down Expand Up @@ -365,11 +362,13 @@ final class BookmarkOutlineViewDataSource: NSObject, NSOutlineViewDataSource, NS
}

}

// MARK: - BookmarkOutlineCellViewDelegate

extension BookmarkOutlineViewDataSource: BookmarkOutlineCellViewDelegate {
func outlineCellViewRequestedMenu(_ cell: BookmarkOutlineCellView) {
onMenuRequestedAction?(cell)
guard let outlineView = cell.superview?.superview as? NSOutlineView else {
assertionFailure("cell.superview?.superview is not NSOutlineView")
return
}
outlineView.menu?.popUpAtMouseLocation(in: cell)
}
}
442 changes: 442 additions & 0 deletions DuckDuckGo/Bookmarks/Services/BookmarksContextMenu.swift

Large diffs are not rendered by default.

278 changes: 0 additions & 278 deletions DuckDuckGo/Bookmarks/Services/ContextualMenu.swift

This file was deleted.

4 changes: 2 additions & 2 deletions DuckDuckGo/Bookmarks/Services/MenuItemSelectors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import AppKit

@objc protocol BookmarksMenuItemSelectors {
func newFolder(_ sender: NSMenuItem)
func newFolder(_ sender: Any?)
func moveToEnd(_ sender: NSMenuItem)
@objc optional func manageBookmarks(_ sender: NSMenuItem)
func manageBookmarks(_ sender: Any?)
}

@objc protocol BookmarkMenuItemSelectors: BookmarksMenuItemSelectors {
Expand Down
58 changes: 58 additions & 0 deletions DuckDuckGo/Bookmarks/View/BookmarkListPopover.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// BookmarkListPopover.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import AppKit
import Foundation

final class BookmarkListPopover: NSPopover {

override init() {
super.init()

self.animates = false
self.behavior = .transient

setupContentController()
}

required init?(coder: NSCoder) {
fatalError("BookmarkListPopover: Bad initializer")
}

// swiftlint:disable:next force_cast
var viewController: BookmarkListViewController { contentViewController as! BookmarkListViewController }

private func setupContentController() {
let controller = BookmarkListViewController()
controller.delegate = self
contentViewController = controller
}

}

extension BookmarkListPopover: BookmarkListViewControllerDelegate {

func popoverShouldClose(_ bookmarkListViewController: BookmarkListViewController) {
close()
}

func popover(shouldPreventClosure: Bool) {
behavior = shouldPreventClosure ? .applicationDefined : .transient
}

}
Loading
Loading