-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sam/add-vpn-agent-approval-state
* main: Bump BrowserServicesKit Version (#2063) Bump autoconsent to 9.1.0 (#2067) Fix casing in some copy items in Preferences and Main Menu (#2070) Fix vertical alignment of privacy feed shield icon (#2069) Fix giving focus to webView when it's loaded in BrowserTabViewController (#2073) Increase polling interval for captcha solver (#2071) Add a link to help page in location permission popup (#2017) Add bookmark popover in SwiftUI (#2036) Better detection of AMP pages (#2001) UI adjustments for improved VPN user control (#2043) Don't override drop operation if source view is webView (#2058) Bump version to 1.71.0 (104) Set marketing version to 1.71.0 Update embedded files
- Loading branch information
Showing
66 changed files
with
2,060 additions
and
1,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
CURRENT_PROJECT_VERSION = 103 | ||
CURRENT_PROJECT_VERSION = 104 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
MARKETING_VERSION = 1.70.0 | ||
MARKETING_VERSION = 1.71.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
DuckDuckGo/Bookmarks/View/AddBookmarkFolderPopoverView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// | ||
// AddBookmarkFolderPopoverView.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 SwiftUI | ||
|
||
struct AddBookmarkFolderPopoverView: ModalView { | ||
|
||
@ObservedObject var model: AddBookmarkFolderPopoverViewModel | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 16) { | ||
Text(UserText.newFolder) | ||
.bold() | ||
|
||
VStack(alignment: .leading, spacing: 7) { | ||
Text("Location:", comment: "Add Folder popover: parent folder picker title") | ||
|
||
BookmarkFolderPicker(folders: model.folders, selectedFolder: $model.parent) | ||
.accessibilityIdentifier("bookmark.folder.folder.dropdown") | ||
.disabled(model.isDisabled) | ||
} | ||
|
||
VStack(alignment: .leading, spacing: 7) { | ||
Text(UserText.newFolderDialogFolderNameTitle) | ||
|
||
TextField("", text: $model.folderName) | ||
.focusedOnAppear() | ||
.accessibilityIdentifier("bookmark.folder.name.textfield") | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
.disabled(model.isDisabled) | ||
} | ||
.padding(.bottom, 16) | ||
|
||
HStack { | ||
Spacer() | ||
|
||
Button(action: { | ||
model.cancel() | ||
}) { | ||
Text(UserText.cancel) | ||
} | ||
.accessibilityIdentifier("bookmark.add.cancel.button") | ||
.disabled(model.isDisabled) | ||
|
||
Button(action: { | ||
model.addFolder() | ||
}) { | ||
Text("Add Folder", comment: "Add Folder popover: Create folder button") | ||
} | ||
.keyboardShortcut(.defaultAction) | ||
.accessibilityIdentifier("bookmark.add.add.folder.button") | ||
.disabled(model.isAddFolderButtonDisabled || model.isDisabled) | ||
} | ||
} | ||
.font(.system(size: 13)) | ||
.padding() | ||
.frame(width: 300, height: 229) | ||
.background(Color(.popoverBackground)) | ||
} | ||
} | ||
|
||
#if DEBUG | ||
#Preview { | ||
let bkman = LocalBookmarkManager(bookmarkStore: BookmarkStoreMock(bookmarks: [ | ||
BookmarkFolder(id: "1", title: "Folder 1", children: [ | ||
BookmarkFolder(id: "2", title: "Nested Folder", children: [ | ||
]) | ||
]), | ||
BookmarkFolder(id: "3", title: "Another Folder", children: [ | ||
BookmarkFolder(id: "4", title: "Nested Folder", children: [ | ||
BookmarkFolder(id: "5", title: "Another Nested Folder", children: [ | ||
]) | ||
]) | ||
]) | ||
])) | ||
bkman.loadBookmarks() | ||
customAssertionFailure = { _, _, _ in } | ||
|
||
return AddBookmarkFolderPopoverView(model: AddBookmarkFolderPopoverViewModel(bookmarkManager: bkman) { | ||
print("CompletionHandler:", $0?.title ?? "<nil>") | ||
}) | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// AddBookmarkPopover.swift | ||
// | ||
// Copyright © 2021 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 SwiftUI | ||
|
||
final class AddBookmarkPopover: NSPopover { | ||
|
||
var isNew: Bool = false | ||
var bookmark: Bookmark? { | ||
didSet { | ||
setupBookmarkAddController() | ||
} | ||
} | ||
|
||
private weak var addressBar: NSView? | ||
|
||
/// prefferred bounding box for the popover positioning | ||
override var boundingFrame: NSRect { | ||
guard let addressBar, | ||
let window = addressBar.window else { return .infinite } | ||
var frame = window.convertToScreen(addressBar.convert(addressBar.bounds, to: nil)) | ||
|
||
frame = frame.insetBy(dx: -42, dy: -window.frame.size.height) | ||
|
||
return frame | ||
} | ||
|
||
override init() { | ||
super.init() | ||
|
||
animates = false | ||
behavior = .transient | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("BookmarksPopover: Bad initializer") | ||
} | ||
|
||
private func setupBookmarkAddController() { | ||
guard let bookmark else { return } | ||
contentViewController = NSHostingController(rootView: AddBookmarkPopoverView(model: AddBookmarkPopoverViewModel(bookmark: bookmark)) | ||
.legacyOnDismiss { [weak self] in | ||
self?.performClose(nil) | ||
}) | ||
} | ||
|
||
override func show(relativeTo positioningRect: NSRect, of positioningView: NSView, preferredEdge: NSRectEdge) { | ||
self.addressBar = positioningView.superview | ||
super.show(relativeTo: positioningRect, of: positioningView, preferredEdge: preferredEdge) | ||
} | ||
|
||
override func performClose(_ sender: Any?) { | ||
self.close() | ||
} | ||
|
||
func popoverWillClose() { | ||
bookmark = nil | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
// | ||
// AddBookmarkPopoverView.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 SwiftUI | ||
import SwiftUIExtensions | ||
|
||
struct AddBookmarkPopoverView: View { | ||
|
||
@ObservedObject private var model: AddBookmarkPopoverViewModel | ||
@Environment(\.dismiss) private var dismiss | ||
|
||
init(model: AddBookmarkPopoverViewModel) { | ||
self.model = model | ||
} | ||
|
||
var body: some View { | ||
if let addFolderViewModel = model.addFolderViewModel { | ||
AddBookmarkFolderPopoverView(model: addFolderViewModel) | ||
} else { | ||
addBookmarkView | ||
} | ||
} | ||
|
||
@MainActor | ||
private var addBookmarkView: some View { | ||
VStack(alignment: .leading, spacing: 19) { | ||
Text("Bookmark Added", comment: "Bookmark Added popover title") | ||
.fontWeight(.bold) | ||
.padding(.bottom, 4) | ||
|
||
VStack(alignment: .leading, spacing: 10) { | ||
TextField("", text: $model.bookmarkTitle) | ||
.focusedOnAppear() | ||
.accessibilityIdentifier("bookmark.add.name.textfield") | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
.font(.system(size: 14)) | ||
|
||
HStack { | ||
BookmarkFolderPicker(folders: model.folders, | ||
selectedFolder: $model.selectedFolder) | ||
.accessibilityIdentifier("bookmark.add.folder.dropdown") | ||
|
||
Button { | ||
model.addFolderButtonAction() | ||
} label: { | ||
Image(.addFolder) | ||
} | ||
.accessibilityIdentifier("bookmark.add.new.folder.button") | ||
.buttonStyle(StandardButtonStyle()) | ||
} | ||
} | ||
|
||
Divider() | ||
|
||
Button { | ||
model.favoritesButtonAction() | ||
} label: { | ||
HStack(spacing: 8) { | ||
if model.bookmark.isFavorite { | ||
Image(.favoriteFilled) | ||
Text(UserText.removeFromFavorites) | ||
} else { | ||
Image(.favorite) | ||
Text(UserText.addToFavorites) | ||
} | ||
} | ||
} | ||
.accessibilityIdentifier("bookmark.add.add.to.favorites.button") | ||
.buttonStyle(.borderless) | ||
.foregroundColor(Color.button) | ||
|
||
HStack { | ||
Spacer() | ||
|
||
Button { | ||
model.removeButtonAction(dismiss: dismiss.callAsFunction) | ||
} label: { | ||
Text("Remove", comment: "Remove bookmark button title") | ||
} | ||
.accessibilityIdentifier("bookmark.add.remove.button") | ||
|
||
Button { | ||
model.doneButtonAction(dismiss: dismiss.callAsFunction) | ||
} label: { | ||
Text(UserText.done) | ||
} | ||
.keyboardShortcut(.defaultAction) | ||
.accessibilityIdentifier("bookmark.add.done.button") | ||
} | ||
|
||
} | ||
.font(.system(size: 13)) | ||
.padding(EdgeInsets(top: 19, leading: 19, bottom: 19, trailing: 19)) | ||
.frame(width: 300, height: 229) | ||
.background(Color(.popoverBackground)) | ||
} | ||
|
||
} | ||
|
||
#if DEBUG | ||
#Preview { { | ||
let bkm = Bookmark(id: "n", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: false, parentFolderUUID: "1") | ||
let bkman = LocalBookmarkManager(bookmarkStore: BookmarkStoreMock(bookmarks: [ | ||
BookmarkFolder(id: "1", title: "Folder 1", children: [ | ||
bkm, | ||
BookmarkFolder(id: "2", title: "Nested Folder", children: [ | ||
]) | ||
]), | ||
Bookmark(id: "b2", url: URL.duckDuckGo.absoluteString, title: "DuckDuckGo", isFavorite: true, parentFolderUUID: "1"), | ||
BookmarkFolder(id: "3", title: "Another Folder", children: [ | ||
BookmarkFolder(id: "4", title: "Nested Folder", children: [ | ||
BookmarkFolder(id: "5", title: "Another Nested Folder", children: [ | ||
]) | ||
]) | ||
]) | ||
])) | ||
bkman.loadBookmarks() | ||
customAssertionFailure = { _, _, _ in } | ||
|
||
return AddBookmarkPopoverView(model: AddBookmarkPopoverViewModel(bookmark: bkm, bookmarkManager: bkman)) | ||
}() } | ||
#endif |
Oops, something went wrong.