-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add search by title to bookmark panel UI (#2969)
- Loading branch information
1 parent
52dfd2e
commit 13e8377
Showing
23 changed files
with
498 additions
and
150 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
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/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
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) -> [BookmarkNode] { | ||
let searchResults = bookmarkManager.search(by: searchQuery) | ||
|
||
return rebuildChildNodes(for: searchResults) | ||
} | ||
|
||
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
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.