Skip to content

Commit

Permalink
Merge branch 'main' into sam/add-vpn-agent-approval-state
Browse files Browse the repository at this point in the history
* 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
samsymons committed Jan 18, 2024
2 parents e8dd2eb + b0bc72b commit e9fa4cc
Show file tree
Hide file tree
Showing 66 changed files with 2,060 additions and 1,005 deletions.
2 changes: 1 addition & 1 deletion Configuration/BuildNumber.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 103
CURRENT_PROJECT_VERSION = 104
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 1.70.0
MARKETING_VERSION = 1.71.0
98 changes: 65 additions & 33 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "851187f38974b87889b21259eb442e95aedffafe",
"version" : "101.1.0"
"revision" : "13c6ccd65f45e9940371c28a1a3498ec29ac9d0b",
"version" : "101.1.3"
}
},
{
"identity" : "content-scope-scripts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "bb027f14bec7fbb1a85d308139e7a66686da160e",
"version" : "4.59.0"
"revision" : "0b68b0d404d8d4f32296cd84fa160b18b0aeaf44",
"version" : "4.59.1"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Autoconsent/autoconsent-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion DuckDuckGo/Bookmarks/Model/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import Cocoa
import Bookmarks

internal class BaseBookmarkEntity {
internal class BaseBookmarkEntity: Identifiable {

static func singleEntity(with uuid: String) -> NSFetchRequest<BookmarkEntity> {
let request = BookmarkEntity.fetchRequest()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Bookmarks/View/AddBookmarkFolderModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct AddBookmarkFolderModalView: ModalView {
.fontWeight(.semibold)

HStack(spacing: 16) {
Text("Name:", comment: "New bookmark folder dialog folder name field heading")
Text(UserText.newBookmarkDialogBookmarkNameTitle)
.frame(height: 22)

TextField("", text: $model.folderName)
Expand Down
98 changes: 98 additions & 0 deletions DuckDuckGo/Bookmarks/View/AddBookmarkFolderPopoverView.swift
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
76 changes: 76 additions & 0 deletions DuckDuckGo/Bookmarks/View/AddBookmarkPopover.swift
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
}

}
137 changes: 137 additions & 0 deletions DuckDuckGo/Bookmarks/View/AddBookmarkPopoverView.swift
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
Loading

0 comments on commit e9fa4cc

Please sign in to comment.