-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- SearchScopeDescriptor: new type to describe search scopes and insta…
…ntiate them - SearchScope: - add new class property "descriptor" to allow each scope to return its own descriptor - subclasses: refactor to add "descriptor" implementations, encapsulating everything into its SearchScopeDescriptor that's needed to use each scope respectively, allowing to integrate a search scope with the rest of the app with a single line in SearchScopeDescriptor.all -SearchScope+Registry: extend SearchScope with: - a method to access available scopes based on context and cell style - a concept to allow users to pick a default scope and SearchedContent - ClientViewController: make use of the SearchScope.availableScopes() based on SearchScopeDescriptor.all
- Loading branch information
1 parent
944cea0
commit 1ef2af0
Showing
8 changed files
with
163 additions
and
55 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
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
38 changes: 38 additions & 0 deletions
38
ownCloudAppShared/Client/Search/Scopes/SearchScope+Registry.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,38 @@ | ||
// | ||
// SearchScope+Registry.swift | ||
// ownCloudAppShared | ||
// | ||
// Created by Felix Schwarz on 29.11.24. | ||
// Copyright © 2024 ownCloud GmbH. All rights reserved. | ||
// | ||
|
||
/* | ||
* Copyright (C) 2024, ownCloud GmbH. | ||
* | ||
* This code is covered by the GNU Public License Version 3. | ||
* | ||
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/ | ||
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>. | ||
* | ||
*/ | ||
|
||
import UIKit | ||
import ownCloudSDK | ||
|
||
extension SearchScope { | ||
static var preferredSearchedContent: OCKQLSearchedContent? | ||
|
||
static func availableScopes(for clientContext: ClientContext, cellStyle: CollectionViewCellStyle) -> [SearchScope] { | ||
var scopes : [SearchScope] = [] | ||
|
||
let descriptors = SearchScopeDescriptor.all | ||
|
||
for descriptor in descriptors { | ||
if let scope = descriptor.createSearchScope(clientContext, cellStyle) { | ||
scopes.append(scope) | ||
} | ||
} | ||
|
||
return scopes | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
ownCloudAppShared/Client/Search/Scopes/SearchScopeDescriptor.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,47 @@ | ||
// | ||
// SearchScopeDescriptor.swift | ||
// ownCloudAppShared | ||
// | ||
// Created by Felix Schwarz on 29.11.24. | ||
// Copyright © 2024 ownCloud GmbH. All rights reserved. | ||
// | ||
|
||
/* | ||
* Copyright (C) 2024, ownCloud GmbH. | ||
* | ||
* This code is covered by the GNU Public License Version 3. | ||
* | ||
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/ | ||
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>. | ||
* | ||
*/ | ||
|
||
import UIKit | ||
import ownCloudSDK | ||
|
||
public struct SearchScopeDescriptor { | ||
var identifier: String | ||
|
||
var title: String | ||
var icon: UIImage? | ||
|
||
var searchableContent: OCKQLSearchedContent | ||
|
||
var scopeCreator: (_ clientContext: ClientContext, _ cellStyle: CollectionViewCellStyle?, _ descriptor: SearchScopeDescriptor) -> SearchScope? | ||
|
||
func createSearchScope(_ clientContext: ClientContext, _ cellStyle: CollectionViewCellStyle?) -> SearchScope? { | ||
return self.scopeCreator(clientContext, cellStyle, self) | ||
} | ||
} | ||
|
||
public extension SearchScopeDescriptor { | ||
static var all: [SearchScopeDescriptor] { | ||
return [ | ||
.folder, | ||
.tree, | ||
.drive, | ||
.account, | ||
.server | ||
] | ||
} | ||
} |
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