Skip to content

Commit

Permalink
- UniversalItemListCell:
Browse files Browse the repository at this point in the history
	- add CollectionViewCellStyle.showPathDetails property
	- add CollectionViewCellStyle.StyleOptionKey.showPathDetails
- OCItem+UniversalItemListCellContentProvider: add support for CollectionViewCellStyle.showPathDetails
- ServerSideSearchScope: add server-side search scope
- SearchScope: add convenience method to instantiate ServerSideSearchScope
- ClientItemViewController: add server-side search scope
  • Loading branch information
felix-schwarz committed Nov 7, 2024
1 parent 2958a32 commit 8ee4643
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ownCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
DC2A68D529D492B300BFF393 /* space.tvg in Resources */ = {isa = PBXBuildFile; fileRef = DC2A68D429D492B200BFF393 /* space.tvg */; };
DC2A68D729D4E93300BFF393 /* SharedKeyCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC2A68D629D4E93300BFF393 /* SharedKeyCommands.swift */; };
DC2A8E6A2B57EA8F001F0522 /* AccountControllerSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC2A8E692B57EA8F001F0522 /* AccountControllerSearchViewController.swift */; };
DC2BB5402CD96C1600320384 /* ServerSideSearchScope.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC2BB53F2CD96C1600320384 /* ServerSideSearchScope.swift */; };
DC36885824DC98BF00333600 /* OCFileProviderServiceSession.h in Headers */ = {isa = PBXBuildFile; fileRef = DC36885624DC98BF00333600 /* OCFileProviderServiceSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
DC36885924DC98BF00333600 /* OCFileProviderServiceSession.m in Sources */ = {isa = PBXBuildFile; fileRef = DC36885724DC98BF00333600 /* OCFileProviderServiceSession.m */; };
DC36885D24DD916800333600 /* ownCloudApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCC0855C2293F1FD008CC05C /* ownCloudApp.framework */; };
Expand Down Expand Up @@ -1287,6 +1288,7 @@
DC2A68D429D492B200BFF393 /* space.tvg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = space.tvg; path = "img/filetypes-tvg/space.tvg"; sourceTree = SOURCE_ROOT; };
DC2A68D629D4E93300BFF393 /* SharedKeyCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedKeyCommands.swift; sourceTree = "<group>"; };
DC2A8E692B57EA8F001F0522 /* AccountControllerSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountControllerSearchViewController.swift; sourceTree = "<group>"; };
DC2BB53F2CD96C1600320384 /* ServerSideSearchScope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerSideSearchScope.swift; sourceTree = "<group>"; };
DC321260207EB01B00DB171D /* ThemeImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeImage.swift; sourceTree = "<group>"; };
DC3393A722E0C4ED00DD3DA4 /* icon-available-offline.tvg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "icon-available-offline.tvg"; path = "../img/filetypes-tvg/icon-available-offline.tvg"; sourceTree = "<group>"; };
DC36885624DC98BF00333600 /* OCFileProviderServiceSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OCFileProviderServiceSession.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2452,6 +2454,7 @@
DC24E10628B7BFD6002E4F5B /* ItemSearchScope.swift */,
DC24E10A28B7C185002E4F5B /* SingleFolderSearchScope.swift */,
DC24E10C28B7C19F002E4F5B /* AccountSearchScope.swift */,
DC2BB53F2CD96C1600320384 /* ServerSideSearchScope.swift */,
);
path = Scopes;
sourceTree = "<group>";
Expand Down Expand Up @@ -4720,6 +4723,7 @@
files = (
DC0A357E24C0E43C00FB58FC /* ThemeStyle+Extensions.swift in Sources */,
DCB1B8C829C8F84800BFF393 /* ThemeCSSProgressView.swift in Sources */,
DC2BB5402CD96C1600320384 /* ServerSideSearchScope.swift in Sources */,
DC04FFC827F5B79000F22569 /* CollectionViewController.swift in Sources */,
DC298CA72936250D009FA87F /* ClientSidebarViewController.swift in Sources */,
DC825E352A05083C00BFF393 /* GitInfo.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ extension OCItem: UniversalItemListCellContentProvider {
// Details
var detailItems: [SegmentViewItem] = []

if configuration?.style.showPathDetails == true {
// - path breadcrumbs for style.showPathDetails == true
if let context, let parentLocation = location?.parent {
detailItems = OCLocation.composeSegments(breadcrumbs: parentLocation.breadcrumbs(in: context, includeServerName: false), in: context)
detailItems.append(SegmentViewItem(with: nil, title: "|", style: .plain))
}
}

// - Cloud status
let (cloudStatusIcon, cloudStatusIconAlpha, accessibilityLabel) = cloudStatus(in: context?.core)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,11 @@ public extension UICellAccessory {
public extension CollectionViewCellStyle.StyleOptionKey {
static let showRevealButton = CollectionViewCellStyle.StyleOptionKey(rawValue: "showRevealButton")
static let showMoreButton = CollectionViewCellStyle.StyleOptionKey(rawValue: "showMoreButton")
static let showPathDetails = CollectionViewCellStyle.StyleOptionKey(rawValue: "showPathDetails")
}

public extension CollectionViewCellStyle {
var showRevealButton : Bool {
var showRevealButton: Bool {
get {
return options[.showRevealButton] as? Bool ?? false
}
Expand All @@ -1036,7 +1037,7 @@ public extension CollectionViewCellStyle {
}
}

var showMoreButton : Bool {
var showMoreButton: Bool {
get {
return options[.showMoreButton] as? Bool ?? true
}
Expand All @@ -1045,6 +1046,16 @@ public extension CollectionViewCellStyle {
options[.showMoreButton] = newValue
}
}

var showPathDetails: Bool {
get {
return options[.showPathDetails] as? Bool ?? false
}

set {
options[.showPathDetails] = newValue
}
}
}

extension SegmentViewItem {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// ServerSideSearchScope.swift
// ownCloudAppShared
//
// Created by Felix Schwarz on 04.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
import ownCloudApp

class ServerSideSearchScope: SearchScope {
var searchResult: OCSearchResult?

public override init(with context: ClientContext, cellStyle: CollectionViewCellStyle?, localizedName name: String, localizedPlaceholder placeholder: String? = nil, icon: UIImage? = nil) {
var pathAndRevealCellStyle : CollectionViewCellStyle?

if let cellStyle = cellStyle {
pathAndRevealCellStyle = CollectionViewCellStyle(from: cellStyle, changing: { cellStyle in
cellStyle.showRevealButton = true
cellStyle.showPathDetails = true
})
}

super.init(with: context, cellStyle: pathAndRevealCellStyle, localizedName: name, localizedPlaceholder: placeholder, icon: icon)

tokenizer = SearchTokenizer(scope: self, clientContext: clientContext)
results = nil
}

open override func updateFor(_ searchElements: [SearchElement]) {
let searchTerm = searchElements.composedSearchTerm
let kqlQuery = "*" + searchTerm + "*"

if searchResult?.kqlQuery != kqlQuery, let core = clientContext.core {
searchResult?.cancel()

searchResult = core.searchFiles(withPattern: kqlQuery, limit: 100)
results = searchResult?.results
}
}
}
4 changes: 4 additions & 0 deletions ownCloudAppShared/Client/Search/Scopes/SearchScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ extension SearchScope {
return AccountSearchScope(with: context, cellStyle: cellStyle, localizedName: localizedName, localizedPlaceholder: OCLocalizedString("Search account", nil), icon: OCSymbol.icon(forSymbolName: "person"))
}

static public func serverSideSearch(with context: ClientContext, cellStyle: CollectionViewCellStyle, localizedName: String) -> SearchScope {
return ServerSideSearchScope(with: context, cellStyle: cellStyle, localizedName: localizedName, localizedPlaceholder: OCLocalizedString("Search server", nil), icon: OCSymbol.icon(forSymbolName: "server.rack"))
}

static public func recipientSearch(with context: ClientContext, cellStyle: CollectionViewCellStyle, item: OCItem, localizedName: String) -> SearchScope {
return RecipientSearchScope(with: context, cellStyle: cellStyle, item: item, localizedName: localizedName, localizedPlaceholder: OCLocalizedString("Search for users or groups", nil), icon: OCSymbol.icon(forSymbolName: "person.circle"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,9 @@ open class ClientItemViewController: CollectionViewController, SortBarDelegate,
// - Account
scopes.append(.accountSearch(with: clientContext, cellStyle: cellStyle, localizedName: OCLocalizedString("Account", nil)))

// - Server
scopes.append(.serverSideSearch(with: clientContext, cellStyle: cellStyle, localizedName: OCLocalizedString("Server", nil)))

return scopes
}

Expand Down

0 comments on commit 8ee4643

Please sign in to comment.