-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Search and sort bookmarks in bookmarks panel (#3022)
- Loading branch information
1 parent
13a0783
commit b1f3b21
Showing
40 changed files
with
2,255 additions
and
260 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+3.47 KB
DuckDuckGo/Assets.xcassets/Images/BookmarkEmptySearch.imageset/Bookmarks-Search-Empty.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
DuckDuckGo/Assets.xcassets/Images/BookmarkEmptySearch.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "Bookmarks-Search-Empty.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
DuckDuckGo/Assets.xcassets/Images/BookmarkSortAsc.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "sort-asc.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
DuckDuckGo/Assets.xcassets/Images/BookmarkSortAsc.imageset/sort-asc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
DuckDuckGo/Assets.xcassets/Images/BookmarkSortDesc.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "sort-desc.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
DuckDuckGo/Assets.xcassets/Images/BookmarkSortDesc.imageset/sort-desc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
DuckDuckGo/Assets.xcassets/Images/Search-Bookmarks.imageset/Contents.json
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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "search_bookmarks.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
DuckDuckGo/Assets.xcassets/Images/Search-Bookmarks.imageset/search_bookmarks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
44 changes: 44 additions & 0 deletions
44
DuckDuckGo/Bookmarks/Model/BookmarkListTreeControllerSearchDataSource.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,44 @@ | ||
// | ||
// BookmarkListTreeControllerSearchDataSource.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 Foundation | ||
|
||
final class BookmarkListTreeControllerSearchDataSource: BookmarkTreeControllerSearchDataSource { | ||
private let bookmarkManager: BookmarkManager | ||
|
||
init(bookmarkManager: BookmarkManager) { | ||
self.bookmarkManager = bookmarkManager | ||
} | ||
|
||
func nodes(for searchQuery: String, sortMode: BookmarksSortMode) -> [BookmarkNode] { | ||
let searchResults = bookmarkManager.search(by: searchQuery) | ||
|
||
return rebuildChildNodes(for: searchResults.sorted(by: sortMode)) | ||
} | ||
|
||
private func rebuildChildNodes(for results: [BaseBookmarkEntity]) -> [BookmarkNode] { | ||
let rootNode = BookmarkNode.genericRootNode() | ||
let nodes = results.compactMap { (item) -> BookmarkNode in | ||
let itemNode = rootNode.createChildNode(item) | ||
itemNode.canHaveChildNodes = false | ||
return itemNode | ||
} | ||
|
||
return nodes | ||
} | ||
} |
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
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
Oops, something went wrong.