From 1dd0adeb461bf015e7c4762f6afb575a61a200e8 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 10:31:30 +0100 Subject: [PATCH 01/22] code Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 10 +- .../NCCollectionViewCommon+CellForItem.swift | 440 ++++++++++++++++++ ...nViewCommon+CollectionViewDataSource.swift | 430 +---------------- .../NCCollectionViewCommon.swift | 13 +- 4 files changed, 458 insertions(+), 435 deletions(-) create mode 100644 iOSClient/Main/Collection Common/NCCollectionViewCommon+CellForItem.swift diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 7821d41ee7..bd97b05e34 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -728,6 +728,7 @@ F7C30DFE291BD0B80017149B /* NCNetworkingE2EEDelete.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFC291BD0B80017149B /* NCNetworkingE2EEDelete.swift */; }; F7C30E00291BD2610017149B /* NCNetworkingE2EERename.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */; }; F7C30E01291BD2610017149B /* NCNetworkingE2EERename.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */; }; + F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellForItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellForItem.swift */; }; F7C687E92D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; F7C687EA2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; F7C687EB2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; @@ -1684,6 +1685,7 @@ F7C30DF9291BCF790017149B /* NCNetworkingE2EECreateFolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EECreateFolder.swift; sourceTree = ""; }; F7C30DFC291BD0B80017149B /* NCNetworkingE2EEDelete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EEDelete.swift; sourceTree = ""; }; F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EERename.swift; sourceTree = ""; }; + F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellForItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+CellForItem.swift"; sourceTree = ""; }; F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCManageDatabase+RecommendedFiles.swift"; sourceTree = ""; }; F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerQuickLook.swift; sourceTree = ""; }; F7C9555221F0C4CA0024296E /* NCActivity.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCActivity.storyboard; sourceTree = ""; }; @@ -2475,9 +2477,9 @@ isa = PBXGroup; children = ( F75FE06B2BB01D0D00A0EFEF /* Cell */, - F78ACD50219046AC0088454D /* Section Header Footer */, F70D7C3525FFBF81002B9E34 /* NCCollectionViewCommon.swift */, F7CAFE172F164B9200DB35A5 /* NCCollectionViewCommon+CellDelegate.swift */, + F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellForItem.swift */, F7743A132C33F13A0034F670 /* NCCollectionViewCommon+CollectionViewDataSource.swift */, F74D50342C9855A000BBBF4C /* NCCollectionViewCommon+CollectionViewDataSourcePrefetching.swift */, F7743A112C33F0A20034F670 /* NCCollectionViewCommon+CollectionViewDelegate.swift */, @@ -2485,14 +2487,15 @@ F7D890742BD25C570050B8A6 /* NCCollectionViewCommon+DragDrop.swift */, F799DF872C4B83CC003410B5 /* NCCollectionViewCommon+EasyTipView.swift */, F799DF8A2C4B84EB003410B5 /* NCCollectionViewCommon+EndToEndInitialize.swift */, - F7865FF02F39D32500D09AE4 /* NCCollectionViewCommon+Search.swift */, - F7CCAB502ECF315F00F8E68B /* NCCollectionViewCommon+SyncMetadata.swift */, F778231D2C42C07C001BB94F /* NCCollectionViewCommon+MediaLayout.swift */, + F7865FF02F39D32500D09AE4 /* NCCollectionViewCommon+Search.swift */, F36E64F62B9245210085ABB5 /* NCCollectionViewCommon+SelectTabBarDelegate.swift */, + F7CCAB502ECF315F00F8E68B /* NCCollectionViewCommon+SyncMetadata.swift */, F7D4BF002CA1831600A5E746 /* NCCollectionViewCommonPinchGesture.swift */, F38F71242B6BBDC300473CDC /* NCCollectionViewCommonSelectTabBar.swift */, F7C1EEA425053A9C00866ACC /* NCCollectionViewDataSource.swift */, F7E7AEA42BA32C6500512E52 /* NCCollectionViewDownloadThumbnail.swift */, + F78ACD50219046AC0088454D /* Section Header Footer */, ); path = "Collection Common"; sourceTree = ""; @@ -4508,6 +4511,7 @@ F785EE9D246196DF00B3F945 /* NCNetworkingE2EE.swift in Sources */, F724377B2C10B83E00C7C68D /* NCSharePermissions.swift in Sources */, F317C82E2E844C5300761AEA /* ClientIntegrationUIViewer.swift in Sources */, + F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellForItem.swift in Sources */, F794E13D2BBBFF2E003693D7 /* NCMainTabBarController.swift in Sources */, F7CBC1252BAC8B0000EC1D55 /* NCSectionFirstHeaderEmptyData.swift in Sources */, F7D4BF3D2CA2E8D800A5E746 /* TOPasscodeKeypadView.m in Sources */, diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellForItem.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellForItem.swift new file mode 100644 index 0000000000..bdb8842e38 --- /dev/null +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellForItem.swift @@ -0,0 +1,440 @@ +// SPDX-FileCopyrightText: Nextcloud GmbH +// SPDX-FileCopyrightText: 2026 Marino Faggiana +// SPDX-License-Identifier: GPL-3.0-or-later + +import Foundation +import UIKit +import NextcloudKit +import RealmSwift + +extension NCCollectionViewCommon { + private func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata, ext: String) -> NCPhotoCell { + let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) + + cell.metadata = metadata + // cell.hideButtonMore(true) NO MORE USED + cell.hideImageStatus(true) + + // Image + // + if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { + + cell.previewImageView?.image = image + cell.previewImageView?.contentMode = .scaleAspectFill + + } else { + + if isPinchGestureActive || ext == global.previewExt512 || ext == global.previewExt1024 { + cell.previewImageView?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) + } + + DispatchQueue.global(qos: .userInteractive).async { + let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) + if let image { + self.imageCache.addImageCache(ocId: metadata.ocId, etag: metadata.etag, image: image, ext: ext, cost: indexPath.row) + DispatchQueue.main.async { + cell.previewImageView?.image = image + cell.previewImageView?.contentMode = .scaleAspectFill + } + } else { + DispatchQueue.main.async { + cell.previewImageView?.contentMode = .scaleAspectFit + if metadata.iconName.isEmpty { + cell.previewImageView?.image = NCImageCache.shared.getImageFile() + } else { + cell.previewImageView?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + } + } + } + } + } + + // Edit mode + // + if fileSelect.contains(metadata.ocId) { + cell.selected(true, isEditMode: isEditMode) + } else { + cell.selected(false, isEditMode: isEditMode) + } + + if width > 100 { + // cell.hideButtonMore(false) NO MORE USED + cell.hideImageStatus(false) + } + + return cell + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + var cell: NCCellProtocol & UICollectionViewCell + var isShare = false + var isMounted = false + var a11yValues: [String] = [] + let metadata = self.dataSource.getMetadata(indexPath: indexPath) ?? tableMetadata() + let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) + let ext = global.getSizeExtension(column: self.numberOfColumns) + + defer { + let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() + if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { + cell.hideButtonShare(true) + } + } + + // E2EE create preview + if self.isDirectoryE2EE, + metadata.isImageOrVideo, + !utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) { + utility.createImageFileFrom(metadata: metadata) + } + + // LAYOUT PHOTO + if isLayoutPhoto { + if metadata.isImageOrVideo { + let photoCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "photoCell", for: indexPath) as? NCPhotoCell)! + photoCell.delegate = self + cell = photoCell + return self.photoCell(cell: photoCell, indexPath: indexPath, metadata: metadata, ext: ext) + } else { + let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! + gridCell.delegate = self + cell = gridCell + } + } else if isLayoutGrid { + // LAYOUT GRID + let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! + gridCell.delegate = self + cell = gridCell + } else { + // LAYOUT LIST + let listCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell)! + listCell.delegate = self + cell = listCell + } + + // CONTENT MODE + cell.avatarImageView?.contentMode = .center + cell.previewImageView?.layer.borderWidth = 0 + + if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { + cell.previewImageView?.contentMode = .scaleAspectFill + } else { + cell.previewImageView?.contentMode = .scaleAspectFit + } + + guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { + return cell + } + + if metadataFolder != nil { + isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) + isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) + } + + if isSearchingMode { + if metadata.name == global.appName { + cell.info?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) + } else { + cell.info?.text = metadata.subline + } + cell.subInfo?.isHidden = true + } else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { + cell.subInfo?.isHidden = false + cell.info?.text = metadata.sessionError + } else { + cell.subInfo?.isHidden = false + cell.writeInfoDateSize(date: metadata.date, size: metadata.size) + } + + cell.title?.text = metadata.fileNameView + + // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { + if metadata.ownerId != metadata.userId { + a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName) + } + + if metadata.directory { + let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) + + if metadata.e2eEncrypted { + cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) + } else if isShare { + cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { + cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) + } else if metadata.mountType == "group" { + cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) + } else if isMounted { + cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) + } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { + cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + } else { + cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) + } + + // Local image: offline + metadata.isOffline = tblDirectory?.offline ?? false + + if metadata.isOffline { + cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } + + // color folder + cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + + } else { + let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + + if metadata.hasPreviewBorder { + cell.previewImageView?.layer.borderWidth = 0.2 + cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor + } + + if metadata.name == global.appName { + if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { + cell.previewImageView?.image = image + } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { + cell.previewImageView?.image = image + } + + if cell.previewImageView?.image == nil { + if metadata.iconName.isEmpty { + cell.previewImageView?.image = NCImageCache.shared.getImageFile() + } else { + cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + } + } + } else { + // APP NAME - UNIFIED SEARCH + switch metadata.iconName { + case let str where str.contains("contacts"): + cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("conversation"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("calendar"): + cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("deck"): + cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("mail"): + cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("talk"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("confirm"): + cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("pages"): + cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + default: + cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + } + if !metadata.iconUrl.isEmpty { + if let ownerId = getAvatarFromIconUrl(metadata: metadata) { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.previewImageView?.image = image + } else { + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.previewImageView?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: collectionView, isPreviewImageView: true)) + } + } + } + } + } + } + + // Local image: offline + metadata.isOffline = tableLocalFile?.offline ?? false + + if metadata.isOffline { + a11yValues.append(NSLocalizedString("_offline_", comment: "")) + cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } else if utilityFileSystem.fileProviderStorageExists(metadata) { + cell.localImageView?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + } + } + + // image Favorite + if metadata.favorite { + cell.favoriteImageView?.image = imageCache.getImageFavorite() + a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) + } + + // Share image + if isShare { + cell.shareImageView?.image = imageCache.getImageShared() + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.shareImageView?.image = imageCache.getImageShareByLink()) : + (cell.shareImageView?.image = imageCache.getImageShared()) + } else { + cell.shareImageView?.image = imageCache.getImageCanShare() + } + + // Button More + if metadata.lock == true { + cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) + a11yValues.append(String(format: NSLocalizedString("_locked_by_", comment: ""), metadata.lockOwnerDisplayName)) + } else { + cell.setButtonMore(image: imageCache.getImageButtonMore()) + } + + // Status + if metadata.isLivePhoto { + cell.statusImageView?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) + } else if metadata.isVideo { + cell.statusImageView?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + } + + switch metadata.status { + case global.metadataStatusWaitCreateFolder: + cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + case global.metadataStatusWaitFavorite: + cell.statusImageView?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + case global.metadataStatusWaitCopy: + cell.statusImageView?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_copy_", comment: "") + case global.metadataStatusWaitMove: + cell.statusImageView?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_move_", comment: "") + case global.metadataStatusWaitRename: + cell.statusImageView?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_rename_", comment: "") + case global.metadataStatusWaitDownload: + cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloading: + cell.statusImageView?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloadError, global.metadataStatusUploadError: + cell.statusImageView?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + default: + break + } + + // AVATAR + if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = image + } else { + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: collectionView)) + } + } + } + } + + // URL + if metadata.classFile == NKTypeClassFile.url.rawValue { + cell.localImageView?.image = nil + cell.hideButtonShare(true) + cell.hideButtonMore(true) + } + + // Separator + if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { + cell.separatorView?.isHidden = true + } else { + cell.separatorView?.isHidden = false + } + + // Edit mode + if fileSelect.contains(metadata.ocId) { + cell.selected(true, isEditMode: isEditMode) + a11yValues.append(NSLocalizedString("_selected_", comment: "")) + } else { + cell.selected(false, isEditMode: isEditMode) + } + + // Accessibility + cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.info?.text ?? "") + (cell.subInfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) + + // Color string find in search + cell.title?.textColor = NCBrandColor.shared.textColor + cell.title?.font = .systemFont(ofSize: 15) + + if isSearchingMode, + let searchResultStore, + let title = cell.title?.text { + let longestWordRange = (title.lowercased() as NSString).range(of: searchResultStore) + let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) + attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) + cell.title?.attributedText = attributedString + } + + // TAGS + cell.setTags(tags: Array(metadata.tags)) + + // SearchingMode - TAG Separator Hidden + if isSearchingMode { + cell.tagSeparator?.isHidden = true + } + + // Layout photo + if isLayoutPhoto { + let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) + + cell.hideImageFavorite(false) + cell.hideImageLocal(false) + cell.hideImageItem(false) + cell.hideButtonMore(false) + cell.hideLabelInfo(false) + cell.hideLabelSubinfo(false) + cell.hideImageStatus(false) + cell.title?.font = UIFont.systemFont(ofSize: 15) + + if width < 120 { + cell.hideImageFavorite(true) + cell.hideImageLocal(true) + cell.title?.font = UIFont.systemFont(ofSize: 10) + if width < 100 { + cell.hideImageItem(true) + cell.hideButtonMore(true) + cell.hideLabelInfo(true) + cell.hideLabelSubinfo(true) + cell.hideImageStatus(true) + } + } + } + + // Hide buttons + if metadata.name != global.appName { + cell.titleInfoTrailingFull() + cell.hideButtonShare(true) + cell.hideButtonMore(true) + } + + cell.setIconOutlines() + + // Obligatory here, at the end !! + cell.metadata = metadata + + return cell + } + +} diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift index 0464e787d9..cbd5baa872 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift @@ -54,435 +54,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } - private func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata, ext: String) -> NCPhotoCell { - let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) - - cell.metadata = metadata - // cell.hideButtonMore(true) NO MORE USED - cell.hideImageStatus(true) - - // Image - // - if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - - cell.previewImageView?.image = image - cell.previewImageView?.contentMode = .scaleAspectFill - - } else { - - if isPinchGestureActive || ext == global.previewExt512 || ext == global.previewExt1024 { - cell.previewImageView?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) - } - - DispatchQueue.global(qos: .userInteractive).async { - let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) - if let image { - self.imageCache.addImageCache(ocId: metadata.ocId, etag: metadata.etag, image: image, ext: ext, cost: indexPath.row) - DispatchQueue.main.async { - cell.previewImageView?.image = image - cell.previewImageView?.contentMode = .scaleAspectFill - } - } else { - DispatchQueue.main.async { - cell.previewImageView?.contentMode = .scaleAspectFit - if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() - } else { - cell.previewImageView?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) - } - } - } - } - } - - // Edit mode - // - if fileSelect.contains(metadata.ocId) { - cell.selected(true, isEditMode: isEditMode) - } else { - cell.selected(false, isEditMode: isEditMode) - } - - if width > 100 { - // cell.hideButtonMore(false) NO MORE USED - cell.hideImageStatus(false) - } - - return cell - } - - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - var cell: NCCellProtocol & UICollectionViewCell - var isShare = false - var isMounted = false - var a11yValues: [String] = [] - let metadata = self.dataSource.getMetadata(indexPath: indexPath) ?? tableMetadata() - let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) - let ext = global.getSizeExtension(column: self.numberOfColumns) - - defer { - let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() - if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { - cell.hideButtonShare(true) - } - } - - // E2EE create preview - if self.isDirectoryE2EE, - metadata.isImageOrVideo, - !utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) { - utility.createImageFileFrom(metadata: metadata) - } - - // LAYOUT PHOTO - if isLayoutPhoto { - if metadata.isImageOrVideo { - let photoCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "photoCell", for: indexPath) as? NCPhotoCell)! - photoCell.delegate = self - cell = photoCell - return self.photoCell(cell: photoCell, indexPath: indexPath, metadata: metadata, ext: ext) - } else { - let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! - gridCell.delegate = self - cell = gridCell - } - } else if isLayoutGrid { - // LAYOUT GRID - let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! - gridCell.delegate = self - cell = gridCell - } else { - // LAYOUT LIST - let listCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell)! - listCell.delegate = self - cell = listCell - } - - // CONTENT MODE - cell.avatarImageView?.contentMode = .center - cell.previewImageView?.layer.borderWidth = 0 - - if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { - cell.previewImageView?.contentMode = .scaleAspectFill - } else { - cell.previewImageView?.contentMode = .scaleAspectFit - } - - guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { - return cell - } - - if metadataFolder != nil { - isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) - isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) - } - - if isSearchingMode { - if metadata.name == global.appName { - cell.info?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) - } else { - cell.info?.text = metadata.subline - } - cell.subInfo?.isHidden = true - } else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { - cell.subInfo?.isHidden = false - cell.info?.text = metadata.sessionError - } else { - cell.subInfo?.isHidden = false - cell.writeInfoDateSize(date: metadata.date, size: metadata.size) - } - - cell.title?.text = metadata.fileNameView - - // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { - if metadata.ownerId != metadata.userId { - a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName) - } - - if metadata.directory { - let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) - - if metadata.e2eEncrypted { - cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) - } else if isShare { - cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) - } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) - } else if metadata.mountType == "group" { - cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) - } else if isMounted { - cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) - } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) - } else { - cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) - } - - // Local image: offline - metadata.isOffline = tblDirectory?.offline ?? false - - if metadata.isOffline { - cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } - - // color folder - cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) - - } else { - let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - - if metadata.hasPreviewBorder { - cell.previewImageView?.layer.borderWidth = 0.2 - cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor - } - - if metadata.name == global.appName { - if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImageView?.image = image - } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImageView?.image = image - } - - if cell.previewImageView?.image == nil { - if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() - } else { - cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) - } - } - } else { - // APP NAME - UNIFIED SEARCH - switch metadata.iconName { - case let str where str.contains("contacts"): - cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("conversation"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("calendar"): - cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("deck"): - cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("mail"): - cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("talk"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("confirm"): - cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("pages"): - cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) - default: - cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) - } - if !metadata.iconUrl.isEmpty { - if let ownerId = getAvatarFromIconUrl(metadata: metadata) { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImageView?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.previewImageView?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: collectionView, isPreviewImageView: true)) - } - } - } - } - } - } - - // Local image: offline - metadata.isOffline = tableLocalFile?.offline ?? false - - if metadata.isOffline { - a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.localImageView?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) - } - } - - // image Favorite - if metadata.favorite { - cell.favoriteImageView?.image = imageCache.getImageFavorite() - a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) - } - - // Share image - if isShare { - cell.shareImageView?.image = imageCache.getImageShared() - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.shareImageView?.image = imageCache.getImageShareByLink()) : - (cell.shareImageView?.image = imageCache.getImageShared()) - } else { - cell.shareImageView?.image = imageCache.getImageCanShare() - } - - // Button More - if metadata.lock == true { - cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) - a11yValues.append(String(format: NSLocalizedString("_locked_by_", comment: ""), metadata.lockOwnerDisplayName)) - } else { - cell.setButtonMore(image: imageCache.getImageButtonMore()) - } - - // Status - if metadata.isLivePhoto { - cell.statusImageView?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) - a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) - } else if metadata.isVideo { - cell.statusImageView?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) - } - - switch metadata.status { - case global.metadataStatusWaitCreateFolder: - cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") - case global.metadataStatusWaitFavorite: - cell.statusImageView?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_favorite_", comment: "") - case global.metadataStatusWaitCopy: - cell.statusImageView?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_copy_", comment: "") - case global.metadataStatusWaitMove: - cell.statusImageView?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_move_", comment: "") - case global.metadataStatusWaitRename: - cell.statusImageView?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_rename_", comment: "") - case global.metadataStatusWaitDownload: - cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloading: - cell.statusImageView?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.statusImageView?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) - default: - break - } - - // AVATAR - if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: collectionView)) - } - } - } - } - - // URL - if metadata.classFile == NKTypeClassFile.url.rawValue { - cell.localImageView?.image = nil - cell.hideButtonShare(true) - cell.hideButtonMore(true) - } - - // Separator - if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { - cell.separatorView?.isHidden = true - } else { - cell.separatorView?.isHidden = false - } - - // Edit mode - if fileSelect.contains(metadata.ocId) { - cell.selected(true, isEditMode: isEditMode) - a11yValues.append(NSLocalizedString("_selected_", comment: "")) - } else { - cell.selected(false, isEditMode: isEditMode) - } - - // Accessibility - cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.info?.text ?? "") + (cell.subInfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) - - // Color string find in search - cell.title?.textColor = NCBrandColor.shared.textColor - cell.title?.font = .systemFont(ofSize: 15) - - if isSearchingMode, - let searchResultStore, - let title = cell.title?.text { - let longestWordRange = (title.lowercased() as NSString).range(of: searchResultStore) - let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) - attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) - cell.title?.attributedText = attributedString - } - - // TAGS - cell.setTags(tags: Array(metadata.tags)) - - // SearchingMode - TAG Separator Hidden - if isSearchingMode { - cell.tagSeparator?.isHidden = true - } - - // Layout photo - if isLayoutPhoto { - let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) - - cell.hideImageFavorite(false) - cell.hideImageLocal(false) - cell.hideImageItem(false) - cell.hideButtonMore(false) - cell.hideLabelInfo(false) - cell.hideLabelSubinfo(false) - cell.hideImageStatus(false) - cell.title?.font = UIFont.systemFont(ofSize: 15) - - if width < 120 { - cell.hideImageFavorite(true) - cell.hideImageLocal(true) - cell.title?.font = UIFont.systemFont(ofSize: 10) - if width < 100 { - cell.hideImageItem(true) - cell.hideButtonMore(true) - cell.hideLabelInfo(true) - cell.hideLabelSubinfo(true) - cell.hideImageStatus(true) - } - } - } - - // Hide buttons - if metadata.name != global.appName { - cell.titleInfoTrailingFull() - cell.hideButtonShare(true) - cell.hideButtonMore(true) - } - - cell.setIconOutlines() - - // Obligatory here, at the end !! - cell.metadata = metadata - - return cell - } - + func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { func setContent(header: UICollectionReusableView, indexPath: IndexPath) { let (heightHeaderRichWorkspace, heightHeaderRecommendations, heightHeaderSection) = getHeaderHeight(section: indexPath.section) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 51fdabae6f..543362aea8 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -375,11 +375,18 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate, if traitCollection.horizontalSizeClass == .regular { textField?.backgroundColor = nil textField?.layer.cornerRadius = 0 + textField?.layer.shadowOpacity = 0 } else { - textField?.backgroundColor = UIColor.systemGray.withAlphaComponent(0.30) + textField?.backgroundColor = UIColor { trait in + trait.userInterfaceStyle == .dark ? UIColor.systemGray.withAlphaComponent(0.20) : .white + } textField?.borderStyle = .none - textField?.layer.cornerRadius = 20 - textField?.clipsToBounds = true + textField?.layer.cornerRadius = 21 + textField?.layer.masksToBounds = false + textField?.layer.shadowColor = UIColor.black.withAlphaComponent(0.10).cgColor + textField?.layer.shadowOpacity = 1 + textField?.layer.shadowOffset = .zero + textField?.layer.shadowRadius = 1.1 } } From 95eb487c070c2f4cec1af5d1a98ec3defaaef29d Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 10:53:13 +0100 Subject: [PATCH 02/22] code Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 12 +- ...> NCCollectionViewCommon+CellLayout.swift} | 370 ++++++++++++++++-- ...nViewCommon+CollectionViewDataSource.swift | 45 +++ 3 files changed, 385 insertions(+), 42 deletions(-) rename iOSClient/Main/Collection Common/{NCCollectionViewCommon+CellForItem.swift => NCCollectionViewCommon+CellLayout.swift} (52%) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index bd97b05e34..6c3541fcb8 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -728,7 +728,7 @@ F7C30DFE291BD0B80017149B /* NCNetworkingE2EEDelete.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFC291BD0B80017149B /* NCNetworkingE2EEDelete.swift */; }; F7C30E00291BD2610017149B /* NCNetworkingE2EERename.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */; }; F7C30E01291BD2610017149B /* NCNetworkingE2EERename.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */; }; - F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellForItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellForItem.swift */; }; + F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellLayout.swift */; }; F7C687E92D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; F7C687EA2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; F7C687EB2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; @@ -1685,7 +1685,7 @@ F7C30DF9291BCF790017149B /* NCNetworkingE2EECreateFolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EECreateFolder.swift; sourceTree = ""; }; F7C30DFC291BD0B80017149B /* NCNetworkingE2EEDelete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EEDelete.swift; sourceTree = ""; }; F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EERename.swift; sourceTree = ""; }; - F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellForItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+CellForItem.swift"; sourceTree = ""; }; + F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+CellLayout.swift"; sourceTree = ""; }; F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCManageDatabase+RecommendedFiles.swift"; sourceTree = ""; }; F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerQuickLook.swift; sourceTree = ""; }; F7C9555221F0C4CA0024296E /* NCActivity.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCActivity.storyboard; sourceTree = ""; }; @@ -2479,7 +2479,7 @@ F75FE06B2BB01D0D00A0EFEF /* Cell */, F70D7C3525FFBF81002B9E34 /* NCCollectionViewCommon.swift */, F7CAFE172F164B9200DB35A5 /* NCCollectionViewCommon+CellDelegate.swift */, - F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellForItem.swift */, + F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellLayout.swift */, F7743A132C33F13A0034F670 /* NCCollectionViewCommon+CollectionViewDataSource.swift */, F74D50342C9855A000BBBF4C /* NCCollectionViewCommon+CollectionViewDataSourcePrefetching.swift */, F7743A112C33F0A20034F670 /* NCCollectionViewCommon+CollectionViewDelegate.swift */, @@ -4511,7 +4511,7 @@ F785EE9D246196DF00B3F945 /* NCNetworkingE2EE.swift in Sources */, F724377B2C10B83E00C7C68D /* NCSharePermissions.swift in Sources */, F317C82E2E844C5300761AEA /* ClientIntegrationUIViewer.swift in Sources */, - F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellForItem.swift in Sources */, + F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellLayout.swift in Sources */, F794E13D2BBBFF2E003693D7 /* NCMainTabBarController.swift in Sources */, F7CBC1252BAC8B0000EC1D55 /* NCSectionFirstHeaderEmptyData.swift in Sources */, F7D4BF3D2CA2E8D800A5E746 /* TOPasscodeKeypadView.m in Sources */, @@ -5751,7 +5751,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -5817,7 +5817,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellForItem.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift similarity index 52% rename from iOSClient/Main/Collection Common/NCCollectionViewCommon+CellForItem.swift rename to iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift index bdb8842e38..926cfac9d7 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellForItem.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift @@ -8,8 +8,11 @@ import NextcloudKit import RealmSwift extension NCCollectionViewCommon { - private func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata, ext: String) -> NCPhotoCell { + // MARK: - LAYOUT PHOTO + // + internal func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata) -> NCPhotoCell { let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) + let ext = global.getSizeExtension(column: self.numberOfColumns) cell.metadata = metadata // cell.hideButtonMore(true) NO MORE USED @@ -65,53 +68,349 @@ extension NCCollectionViewCommon { return cell } - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - var cell: NCCellProtocol & UICollectionViewCell + // MARK: - LAYOUT GRID + // + internal func gridCell(cell: NCGridCell, indexPath: IndexPath, metadata: tableMetadata) -> NCGridCell { var isShare = false var isMounted = false var a11yValues: [String] = [] - let metadata = self.dataSource.getMetadata(indexPath: indexPath) ?? tableMetadata() - let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) let ext = global.getSizeExtension(column: self.numberOfColumns) + let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) - defer { - let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() - if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { - cell.hideButtonShare(true) + // CONTENT MODE + cell.avatarImageView?.contentMode = .center + cell.previewImageView?.layer.borderWidth = 0 + + if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { + cell.previewImageView?.contentMode = .scaleAspectFill + } else { + cell.previewImageView?.contentMode = .scaleAspectFit + } + + guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { + return cell + } + + if metadataFolder != nil { + isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) + isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) + } + + if isSearchingMode { + if metadata.name == global.appName { + cell.info?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) + } else { + cell.info?.text = metadata.subline } + cell.subInfo?.isHidden = true + } else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { + cell.subInfo?.isHidden = false + cell.info?.text = metadata.sessionError + } else { + cell.subInfo?.isHidden = false + cell.writeInfoDateSize(date: metadata.date, size: metadata.size) } - // E2EE create preview - if self.isDirectoryE2EE, - metadata.isImageOrVideo, - !utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) { - utility.createImageFileFrom(metadata: metadata) + cell.title?.text = metadata.fileNameView + + // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { + if metadata.ownerId != metadata.userId { + a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName) } - // LAYOUT PHOTO - if isLayoutPhoto { - if metadata.isImageOrVideo { - let photoCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "photoCell", for: indexPath) as? NCPhotoCell)! - photoCell.delegate = self - cell = photoCell - return self.photoCell(cell: photoCell, indexPath: indexPath, metadata: metadata, ext: ext) + if metadata.directory { + let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) + + if metadata.e2eEncrypted { + cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) + } else if isShare { + cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { + cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) + } else if metadata.mountType == "group" { + cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) + } else if isMounted { + cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) + } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { + cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + } else { + cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) + } + + // Local image: offline + metadata.isOffline = tblDirectory?.offline ?? false + + if metadata.isOffline { + cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } + + // color folder + cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + + } else { + let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + + if metadata.hasPreviewBorder { + cell.previewImageView?.layer.borderWidth = 0.2 + cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor + } + + if metadata.name == global.appName { + if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { + cell.previewImageView?.image = image + } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { + cell.previewImageView?.image = image + } + + if cell.previewImageView?.image == nil { + if metadata.iconName.isEmpty { + cell.previewImageView?.image = NCImageCache.shared.getImageFile() + } else { + cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + } + } + } else { + // APP NAME - UNIFIED SEARCH + switch metadata.iconName { + case let str where str.contains("contacts"): + cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("conversation"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("calendar"): + cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("deck"): + cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("mail"): + cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("talk"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("confirm"): + cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("pages"): + cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + default: + cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + } + if !metadata.iconUrl.isEmpty { + if let ownerId = getAvatarFromIconUrl(metadata: metadata) { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.previewImageView?.image = image + } else { + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.previewImageView?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) + } + } + } + } + } + } + + // Local image: offline + metadata.isOffline = tableLocalFile?.offline ?? false + + if metadata.isOffline { + a11yValues.append(NSLocalizedString("_offline_", comment: "")) + cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } else if utilityFileSystem.fileProviderStorageExists(metadata) { + cell.localImageView?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + } + } + + // image Favorite + if metadata.favorite { + cell.favoriteImageView?.image = imageCache.getImageFavorite() + a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) + } + + // Share image + if isShare { + cell.shareImageView?.image = imageCache.getImageShared() + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.shareImageView?.image = imageCache.getImageShareByLink()) : + (cell.shareImageView?.image = imageCache.getImageShared()) + } else { + cell.shareImageView?.image = imageCache.getImageCanShare() + } + + // Button More + if metadata.lock == true { + cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) + a11yValues.append(String(format: NSLocalizedString("_locked_by_", comment: ""), metadata.lockOwnerDisplayName)) + } else { + cell.setButtonMore(image: imageCache.getImageButtonMore()) + } + + // Status + if metadata.isLivePhoto { + cell.statusImageView?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) + } else if metadata.isVideo { + cell.statusImageView?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + } + + switch metadata.status { + case global.metadataStatusWaitCreateFolder: + cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + case global.metadataStatusWaitFavorite: + cell.statusImageView?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + case global.metadataStatusWaitCopy: + cell.statusImageView?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_copy_", comment: "") + case global.metadataStatusWaitMove: + cell.statusImageView?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_move_", comment: "") + case global.metadataStatusWaitRename: + cell.statusImageView?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.info?.text = NSLocalizedString("_status_wait_rename_", comment: "") + case global.metadataStatusWaitDownload: + cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloading: + cell.statusImageView?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloadError, global.metadataStatusUploadError: + cell.statusImageView?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + default: + break + } + + // AVATAR + if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = image } else { - let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! - gridCell.delegate = self - cell = gridCell + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: self.collectionView)) + } + } } - } else if isLayoutGrid { - // LAYOUT GRID - let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! - gridCell.delegate = self - cell = gridCell + } + + // URL + if metadata.classFile == NKTypeClassFile.url.rawValue { + cell.localImageView?.image = nil + cell.hideButtonShare(true) + cell.hideButtonMore(true) + } + + // Separator + if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { + cell.separatorView?.isHidden = true + } else { + cell.separatorView?.isHidden = false + } + + // Edit mode + if fileSelect.contains(metadata.ocId) { + cell.selected(true, isEditMode: isEditMode) + a11yValues.append(NSLocalizedString("_selected_", comment: "")) } else { - // LAYOUT LIST - let listCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell)! - listCell.delegate = self - cell = listCell + cell.selected(false, isEditMode: isEditMode) } + // Accessibility + cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.info?.text ?? "") + (cell.subInfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) + + // Color string find in search + cell.title?.textColor = NCBrandColor.shared.textColor + cell.title?.font = .systemFont(ofSize: 15) + + if isSearchingMode, + let searchResultStore, + let title = cell.title?.text { + let longestWordRange = (title.lowercased() as NSString).range(of: searchResultStore) + let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) + attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) + cell.title?.attributedText = attributedString + } + + // TAGS + cell.setTags(tags: Array(metadata.tags)) + + // SearchingMode - TAG Separator Hidden + if isSearchingMode { + cell.tagSeparator?.isHidden = true + } + + // Layout photo + if isLayoutPhoto { + let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) + + cell.hideImageFavorite(false) + cell.hideImageLocal(false) + cell.hideImageItem(false) + cell.hideButtonMore(false) + cell.hideLabelInfo(false) + cell.hideLabelSubinfo(false) + cell.hideImageStatus(false) + cell.title?.font = UIFont.systemFont(ofSize: 15) + + if width < 120 { + cell.hideImageFavorite(true) + cell.hideImageLocal(true) + cell.title?.font = UIFont.systemFont(ofSize: 10) + if width < 100 { + cell.hideImageItem(true) + cell.hideButtonMore(true) + cell.hideLabelInfo(true) + cell.hideLabelSubinfo(true) + cell.hideImageStatus(true) + } + } + } + + // Hide buttons + if metadata.name != global.appName { + cell.titleInfoTrailingFull() + cell.hideButtonShare(true) + cell.hideButtonMore(true) + } + + cell.setIconOutlines() + + // Obligatory here, at the end !! + cell.metadata = metadata + + return cell + } + + // MARK: - LAYOUT LIST + // + internal func listCell(cell: NCListCell, indexPath: IndexPath, metadata: tableMetadata) -> NCListCell { + var isShare = false + var isMounted = false + var a11yValues: [String] = [] + let ext = global.getSizeExtension(column: self.numberOfColumns) + let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) + // CONTENT MODE cell.avatarImageView?.contentMode = .center cell.previewImageView?.layer.borderWidth = 0 @@ -246,7 +545,7 @@ extension NCCollectionViewCommon { if !(tblAvatar?.loaded ?? false), self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: collectionView, isPreviewImageView: true)) + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) } } } @@ -343,7 +642,7 @@ extension NCCollectionViewCommon { if !(tblAvatar?.loaded ?? false), self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: collectionView)) + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: self.collectionView)) } } } @@ -436,5 +735,4 @@ extension NCCollectionViewCommon { return cell } - } diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift index cbd5baa872..95e58afd14 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift @@ -51,7 +51,52 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { self.networking.downloadThumbnailQueue.operations.filter({ ($0 as? NCMediaDownloadThumbnail)?.metadata.ocId == metadata.ocId }).isEmpty { self.networking.downloadThumbnailQueue.addOperation(NCCollectionViewDownloadThumbnail(metadata: metadata, collectionView: collectionView, ext: ext)) } + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + var cell: NCCellProtocol & UICollectionViewCell + let metadata = self.dataSource.getMetadata(indexPath: indexPath) ?? tableMetadata() + + defer { + let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() + if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { + cell.hideButtonShare(true) + } + } + // E2EE create preview + if self.isDirectoryE2EE, + metadata.isImageOrVideo, + !utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) { + utility.createImageFileFrom(metadata: metadata) + } + + // LAYOUT PHOTO + if isLayoutPhoto { + if metadata.isImageOrVideo { + let photoCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "photoCell", for: indexPath) as? NCPhotoCell)! + photoCell.delegate = self + cell = photoCell + return self.photoCell(cell: photoCell, indexPath: indexPath, metadata: metadata) + } else { + let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! + gridCell.delegate = self + cell = gridCell + return self.gridCell(cell: gridCell, indexPath: indexPath, metadata: metadata) + } + } else if isLayoutGrid { + // LAYOUT GRID + let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! + gridCell.delegate = self + cell = gridCell + return self.gridCell(cell: gridCell, indexPath: indexPath, metadata: metadata) + } else { + // LAYOUT LIST + let listCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell)! + listCell.delegate = self + cell = listCell + return self.listCell(cell: listCell, indexPath: indexPath, metadata: metadata) + } } From 77b0910a45d6940c7f30b6880aec96fdb35fa8fe Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 11:37:26 +0100 Subject: [PATCH 03/22] clean Signed-off-by: Marino Faggiana --- .../NCCollectionViewCommon+CellLayout.swift | 19 +++++++++++++++++++ ...nViewCommon+CollectionViewDataSource.swift | 13 ------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift index 926cfac9d7..6506df67a1 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift @@ -11,9 +11,16 @@ extension NCCollectionViewCommon { // MARK: - LAYOUT PHOTO // internal func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata) -> NCPhotoCell { + defer { + let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() + if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { + cell.hideButtonShare(true) + } + } let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) let ext = global.getSizeExtension(column: self.numberOfColumns) + cell.metadata = metadata // cell.hideButtonMore(true) NO MORE USED cell.hideImageStatus(true) @@ -71,6 +78,12 @@ extension NCCollectionViewCommon { // MARK: - LAYOUT GRID // internal func gridCell(cell: NCGridCell, indexPath: IndexPath, metadata: tableMetadata) -> NCGridCell { + defer { + let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() + if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { + cell.hideButtonShare(true) + } + } var isShare = false var isMounted = false var a11yValues: [String] = [] @@ -405,6 +418,12 @@ extension NCCollectionViewCommon { // MARK: - LAYOUT LIST // internal func listCell(cell: NCListCell, indexPath: IndexPath, metadata: tableMetadata) -> NCListCell { + defer { + let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() + if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { + cell.hideButtonShare(true) + } + } var isShare = false var isMounted = false var a11yValues: [String] = [] diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift index 95e58afd14..aeb2f0ec5e 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift @@ -54,16 +54,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - var cell: NCCellProtocol & UICollectionViewCell let metadata = self.dataSource.getMetadata(indexPath: indexPath) ?? tableMetadata() - defer { - let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() - if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { - cell.hideButtonShare(true) - } - } - // E2EE create preview if self.isDirectoryE2EE, metadata.isImageOrVideo, @@ -76,30 +68,25 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if metadata.isImageOrVideo { let photoCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "photoCell", for: indexPath) as? NCPhotoCell)! photoCell.delegate = self - cell = photoCell return self.photoCell(cell: photoCell, indexPath: indexPath, metadata: metadata) } else { let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! gridCell.delegate = self - cell = gridCell return self.gridCell(cell: gridCell, indexPath: indexPath, metadata: metadata) } } else if isLayoutGrid { // LAYOUT GRID let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! gridCell.delegate = self - cell = gridCell return self.gridCell(cell: gridCell, indexPath: indexPath, metadata: metadata) } else { // LAYOUT LIST let listCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell)! listCell.delegate = self - cell = listCell return self.listCell(cell: listCell, indexPath: indexPath, metadata: metadata) } } - func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { func setContent(header: UICollectionReusableView, indexPath: IndexPath) { let (heightHeaderRichWorkspace, heightHeaderRecommendations, heightHeaderSection) = getHeaderHeight(section: indexPath.section) From 385d59e6d527c44e61d3f4aa9bd57bde2aa9d3cf Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 12:15:52 +0100 Subject: [PATCH 04/22] cleaning Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 4 +- .../Cell/NCCellProtocol.swift | 84 +------ .../Collection Common/Cell/NCGridCell.swift | 24 -- .../Collection Common/Cell/NCListCell.swift | 39 +-- .../Collection Common/Cell/NCPhotoCell.swift | 4 - .../NCCollectionViewCommon+CellLayout.swift | 223 ++++++------------ iOSClient/Recent/NCRecent.swift | 2 +- 7 files changed, 79 insertions(+), 301 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 6c3541fcb8..a81410dbbe 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -2461,10 +2461,10 @@ children = ( 370D26AE248A3D7A00121797 /* NCCellProtocol.swift */, F78ACD3F21903CC20088454D /* NCGridCell.swift */, - F78ACD4521903D010088454D /* NCGridCell.xib */, + F751247A2C42919C00E63DB8 /* NCPhotoCell.swift */, F78ACD4121903CE00088454D /* NCListCell.swift */, + F78ACD4521903D010088454D /* NCGridCell.xib */, F78ACD4321903CF20088454D /* NCListCell.xib */, - F751247A2C42919C00E63DB8 /* NCPhotoCell.swift */, F751247B2C42919C00E63DB8 /* NCPhotoCell.xib */, F75D901E2D2BE12E003E740B /* NCRecommendationsCell.xib */, F75D90202D2BE26C003E740B /* NCRecommendationsCell.swift */, diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index e788a6b1e2..1e7407e898 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -6,100 +6,26 @@ import UIKit protocol NCCellProtocol { var metadata: tableMetadata? {get set } - var avatarImageView: UIImageView? { get } var previewImageView: UIImageView? { get set } - var title: UILabel? { get set } - var info: UILabel? { get set } - var subInfo: UILabel? { get set } - var statusImageView: UIImageView? { get set } - var localImageView: UIImageView? { get set } - var favoriteImageView: UIImageView? { get set } - var shareImageView: UIImageView? { get set } - var separatorView: UIView? { get set } - var tagSeparator: UILabel? { get set } - func titleInfoTrailingFull() - func writeInfoDateSize(date: NSDate, size: Int64) - func setButtonMore(image: UIImage) - func hideImageItem(_ status: Bool) - func hideImageFavorite(_ status: Bool) - func hideImageStatus(_ status: Bool) - func hideImageLocal(_ status: Bool) - func hideLabelInfo(_ status: Bool) - func hideLabelSubinfo(_ status: Bool) - func hideButtonShare(_ status: Bool) func hideButtonMore(_ status: Bool) - func selected(_ status: Bool, isEditMode: Bool) - func setAccessibility(label: String, value: String) - func setTags(tags: [String]) - func setIconOutlines() + func hideImageStatus(_ status: Bool) } extension NCCellProtocol { - var avatarImageView: UIImageView? { - return nil - } var metadata: tableMetadata? { get { return nil } set {} } - var previewImageView: UIImageView? { - get { return nil } - set {} - } - var title: UILabel? { - get { return nil } - set {} - } - var info: UILabel? { - get { return nil } - set { } - } - var subInfo: UILabel? { - get { return nil } - set { } - } - var statusImageView: UIImageView? { - get { return nil } - set {} - } - var localImageView: UIImageView? { - get { return nil } - set {} - } - var favoriteImageView: UIImageView? { - get { return nil } - set {} - } - var shareImageView: UIImageView? { - get { return nil } - set {} - } - - var separatorView: UIView? { - get { return nil } - set {} + var avatarImageView: UIImageView? { + return nil } - - var tagSeparator: UILabel? { + var previewImageView: UIImageView? { get { return nil } set {} } - func titleInfoTrailingFull() {} - func writeInfoDateSize(date: NSDate, size: Int64) {} - func setButtonMore(image: UIImage) {} - func hideImageItem(_ status: Bool) {} - func hideImageFavorite(_ status: Bool) {} - func hideImageStatus(_ status: Bool) {} - func hideImageLocal(_ status: Bool) {} - func hideLabelInfo(_ status: Bool) {} - func hideLabelSubinfo(_ status: Bool) {} - func hideButtonShare(_ status: Bool) {} func hideButtonMore(_ status: Bool) {} - func selected(_ status: Bool, isEditMode: Bool) {} - func setAccessibility(label: String, value: String) {} - func setTags(tags: [String]) {} - func setIconOutlines() {} + func hideImageStatus(_ status: Bool) {} } diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 040aa451c3..1384416135 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -34,30 +34,6 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto get { return imageItem } set { imageItem = newValue } } - var title: UILabel? { - get { return labelTitle } - set { labelTitle = newValue } - } - var info: UILabel? { - get { return labelInfo } - set { labelInfo = newValue } - } - var subInfo: UILabel? { - get { return labelSubinfo } - set { labelSubinfo = newValue } - } - var statusImageView: UIImageView? { - get { return imageStatus } - set { imageStatus = newValue } - } - var localImageView: UIImageView? { - get { return imageLocal } - set { imageLocal = newValue } - } - var favoriteImageView: UIImageView? { - get { return imageFavorite } - set { imageFavorite = newValue } - } override func awakeFromNib() { super.awakeFromNib() diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 2f4df564b6..d9cdee8f9e 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -47,43 +47,8 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto get { return imageItem } set { imageItem = newValue } } - var title: UILabel? { - get { return labelTitle } - set { labelTitle = newValue } - } - var info: UILabel? { - get { return labelInfo } - set { labelInfo = newValue } - } - var subInfo: UILabel? { - get { return labelSubinfo } - set { labelSubinfo = newValue } - } - var statusImageView: UIImageView? { - get { return imageStatus } - set { imageStatus = newValue } - } - var localImageView: UIImageView? { - get { return imageLocal } - set { imageLocal = newValue } - } - var favoriteImageView: UIImageView? { - get { return imageFavorite } - set { imageFavorite = newValue } - } - var shareImageView: UIImageView? { - get { return imageShared } - set { imageShared = newValue } - } - var separatorView: UIView? { - get { return separator } - set { separator = newValue } - } - var tagSeparator: UILabel? { - get { return labelInfoSeparator } - set { labelInfoSeparator = newValue } - } - + + override var accessibilityIdentifier: String? { get { super.accessibilityIdentifier diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index cedf0815a9..5da47dafee 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -28,10 +28,6 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt get { return imageItem } set { imageItem = newValue } } - var statusImageView: UIImageView? { - get { return imageStatus } - set { imageStatus = newValue } - } override func awakeFromNib() { super.awakeFromNib() diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift index 6506df67a1..003ace9ffd 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift @@ -11,16 +11,9 @@ extension NCCollectionViewCommon { // MARK: - LAYOUT PHOTO // internal func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata) -> NCPhotoCell { - defer { - let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() - if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { - cell.hideButtonShare(true) - } - } let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) let ext = global.getSizeExtension(column: self.numberOfColumns) - cell.metadata = metadata // cell.hideButtonMore(true) NO MORE USED cell.hideImageStatus(true) @@ -78,12 +71,6 @@ extension NCCollectionViewCommon { // MARK: - LAYOUT GRID // internal func gridCell(cell: NCGridCell, indexPath: IndexPath, metadata: tableMetadata) -> NCGridCell { - defer { - let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() - if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { - cell.hideButtonShare(true) - } - } var isShare = false var isMounted = false var a11yValues: [String] = [] @@ -109,22 +96,15 @@ extension NCCollectionViewCommon { isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) } - if isSearchingMode { - if metadata.name == global.appName { - cell.info?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) - } else { - cell.info?.text = metadata.subline - } - cell.subInfo?.isHidden = true - } else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { - cell.subInfo?.isHidden = false - cell.info?.text = metadata.sessionError + if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { + cell.labelSubinfo?.isHidden = false + cell.labelInfo?.text = metadata.sessionError } else { - cell.subInfo?.isHidden = false + cell.labelSubinfo?.isHidden = false cell.writeInfoDateSize(date: metadata.date, size: metadata.size) } - cell.title?.text = metadata.fileNameView + cell.labelTitle?.text = metadata.fileNameView // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { if metadata.ownerId != metadata.userId { @@ -158,7 +138,7 @@ extension NCCollectionViewCommon { metadata.isOffline = tblDirectory?.offline ?? false if metadata.isOffline { - cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) } // color folder @@ -237,29 +217,18 @@ extension NCCollectionViewCommon { if metadata.isOffline { a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.localImageView?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) } } // image Favorite if metadata.favorite { - cell.favoriteImageView?.image = imageCache.getImageFavorite() + cell.imageFavorite?.image = imageCache.getImageFavorite() a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) } - // Share image - if isShare { - cell.shareImageView?.image = imageCache.getImageShared() - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.shareImageView?.image = imageCache.getImageShareByLink()) : - (cell.shareImageView?.image = imageCache.getImageShared()) - } else { - cell.shareImageView?.image = imageCache.getImageCanShare() - } - // Button More if metadata.lock == true { cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) @@ -270,34 +239,34 @@ extension NCCollectionViewCommon { // Status if metadata.isLivePhoto { - cell.statusImageView?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) } else if metadata.isVideo { - cell.statusImageView?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) } switch metadata.status { case global.metadataStatusWaitCreateFolder: - cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") case global.metadataStatusWaitFavorite: - cell.statusImageView?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") case global.metadataStatusWaitCopy: - cell.statusImageView?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_copy_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") case global.metadataStatusWaitMove: - cell.statusImageView?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_move_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") case global.metadataStatusWaitRename: - cell.statusImageView?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_rename_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") case global.metadataStatusWaitDownload: - cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloading: - cell.statusImageView?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.statusImageView?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) default: break } @@ -329,18 +298,10 @@ extension NCCollectionViewCommon { // URL if metadata.classFile == NKTypeClassFile.url.rawValue { - cell.localImageView?.image = nil - cell.hideButtonShare(true) + cell.imageLocal?.image = nil cell.hideButtonMore(true) } - // Separator - if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { - cell.separatorView?.isHidden = true - } else { - cell.separatorView?.isHidden = false - } - // Edit mode if fileSelect.contains(metadata.ocId) { cell.selected(true, isEditMode: isEditMode) @@ -350,28 +311,11 @@ extension NCCollectionViewCommon { } // Accessibility - cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.info?.text ?? "") + (cell.subInfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) + cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo?.text ?? "") + (cell.labelSubinfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) // Color string find in search - cell.title?.textColor = NCBrandColor.shared.textColor - cell.title?.font = .systemFont(ofSize: 15) - - if isSearchingMode, - let searchResultStore, - let title = cell.title?.text { - let longestWordRange = (title.lowercased() as NSString).range(of: searchResultStore) - let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) - attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) - cell.title?.attributedText = attributedString - } - - // TAGS - cell.setTags(tags: Array(metadata.tags)) - - // SearchingMode - TAG Separator Hidden - if isSearchingMode { - cell.tagSeparator?.isHidden = true - } + cell.labelTitle?.textColor = NCBrandColor.shared.textColor + cell.labelTitle?.font = .systemFont(ofSize: 15) // Layout photo if isLayoutPhoto { @@ -384,12 +328,12 @@ extension NCCollectionViewCommon { cell.hideLabelInfo(false) cell.hideLabelSubinfo(false) cell.hideImageStatus(false) - cell.title?.font = UIFont.systemFont(ofSize: 15) + cell.labelTitle?.font = UIFont.systemFont(ofSize: 15) if width < 120 { cell.hideImageFavorite(true) cell.hideImageLocal(true) - cell.title?.font = UIFont.systemFont(ofSize: 10) + cell.labelTitle?.font = UIFont.systemFont(ofSize: 10) if width < 100 { cell.hideImageItem(true) cell.hideButtonMore(true) @@ -402,8 +346,6 @@ extension NCCollectionViewCommon { // Hide buttons if metadata.name != global.appName { - cell.titleInfoTrailingFull() - cell.hideButtonShare(true) cell.hideButtonMore(true) } @@ -451,20 +393,20 @@ extension NCCollectionViewCommon { if isSearchingMode { if metadata.name == global.appName { - cell.info?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) + cell.labelInfo?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) } else { - cell.info?.text = metadata.subline + cell.labelInfo?.text = metadata.subline } - cell.subInfo?.isHidden = true + cell.labelSubinfo?.isHidden = true } else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { - cell.subInfo?.isHidden = false - cell.info?.text = metadata.sessionError + cell.labelSubinfo?.isHidden = false + cell.labelInfo?.text = metadata.sessionError } else { - cell.subInfo?.isHidden = false + cell.labelSubinfo?.isHidden = false cell.writeInfoDateSize(date: metadata.date, size: metadata.size) } - cell.title?.text = metadata.fileNameView + cell.labelTitle?.text = metadata.fileNameView // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { if metadata.ownerId != metadata.userId { @@ -498,7 +440,7 @@ extension NCCollectionViewCommon { metadata.isOffline = tblDirectory?.offline ?? false if metadata.isOffline { - cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) } // color folder @@ -577,27 +519,27 @@ extension NCCollectionViewCommon { if metadata.isOffline { a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.localImageView?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.localImageView?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) } } // image Favorite if metadata.favorite { - cell.favoriteImageView?.image = imageCache.getImageFavorite() + cell.imageFavorite?.image = imageCache.getImageFavorite() a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) } // Share image if isShare { - cell.shareImageView?.image = imageCache.getImageShared() + cell.imageShared?.image = imageCache.getImageShared() } else if !metadata.shareType.isEmpty { metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.shareImageView?.image = imageCache.getImageShareByLink()) : - (cell.shareImageView?.image = imageCache.getImageShared()) + (cell.imageShared?.image = imageCache.getImageShareByLink()) : + (cell.imageShared?.image = imageCache.getImageShared()) } else { - cell.shareImageView?.image = imageCache.getImageCanShare() + cell.imageShared?.image = imageCache.getImageCanShare() } // Button More @@ -610,34 +552,34 @@ extension NCCollectionViewCommon { // Status if metadata.isLivePhoto { - cell.statusImageView?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) } else if metadata.isVideo { - cell.statusImageView?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) } switch metadata.status { case global.metadataStatusWaitCreateFolder: - cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") case global.metadataStatusWaitFavorite: - cell.statusImageView?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") case global.metadataStatusWaitCopy: - cell.statusImageView?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_copy_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") case global.metadataStatusWaitMove: - cell.statusImageView?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_move_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") case global.metadataStatusWaitRename: - cell.statusImageView?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.info?.text = NSLocalizedString("_status_wait_rename_", comment: "") + cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") case global.metadataStatusWaitDownload: - cell.statusImageView?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloading: - cell.statusImageView?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.statusImageView?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) default: break } @@ -669,16 +611,16 @@ extension NCCollectionViewCommon { // URL if metadata.classFile == NKTypeClassFile.url.rawValue { - cell.localImageView?.image = nil + cell.imageLocal?.image = nil cell.hideButtonShare(true) cell.hideButtonMore(true) } // Separator if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { - cell.separatorView?.isHidden = true + cell.separator?.isHidden = true } else { - cell.separatorView?.isHidden = false + cell.separator?.isHidden = false } // Edit mode @@ -690,19 +632,19 @@ extension NCCollectionViewCommon { } // Accessibility - cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.info?.text ?? "") + (cell.subInfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) + cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo?.text ?? "") + (cell.labelSubinfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) // Color string find in search - cell.title?.textColor = NCBrandColor.shared.textColor - cell.title?.font = .systemFont(ofSize: 15) + cell.labelTitle?.textColor = NCBrandColor.shared.textColor + cell.labelTitle?.font = .systemFont(ofSize: 15) if isSearchingMode, let searchResultStore, - let title = cell.title?.text { + let title = cell.labelTitle?.text { let longestWordRange = (title.lowercased() as NSString).range(of: searchResultStore) let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) - cell.title?.attributedText = attributedString + cell.labelTitle?.attributedText = attributedString } // TAGS @@ -710,34 +652,7 @@ extension NCCollectionViewCommon { // SearchingMode - TAG Separator Hidden if isSearchingMode { - cell.tagSeparator?.isHidden = true - } - - // Layout photo - if isLayoutPhoto { - let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) - - cell.hideImageFavorite(false) - cell.hideImageLocal(false) - cell.hideImageItem(false) - cell.hideButtonMore(false) - cell.hideLabelInfo(false) - cell.hideLabelSubinfo(false) - cell.hideImageStatus(false) - cell.title?.font = UIFont.systemFont(ofSize: 15) - - if width < 120 { - cell.hideImageFavorite(true) - cell.hideImageLocal(true) - cell.title?.font = UIFont.systemFont(ofSize: 10) - if width < 100 { - cell.hideImageItem(true) - cell.hideButtonMore(true) - cell.hideLabelInfo(true) - cell.hideLabelSubinfo(true) - cell.hideImageStatus(true) - } - } + cell.labelInfoSeparator.isHidden = true } // Hide buttons diff --git a/iOSClient/Recent/NCRecent.swift b/iOSClient/Recent/NCRecent.swift index 2379b3ab4e..1d0bb45377 100644 --- a/iOSClient/Recent/NCRecent.swift +++ b/iOSClient/Recent/NCRecent.swift @@ -141,7 +141,7 @@ class NCRecent: NCCollectionViewCommon { - /Users/marinofaggiana/Developer/ios/iOSClient/Assistant + From d2a565b9e6d1ac6e106b690e068717f0d251a4e9 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 12:33:12 +0100 Subject: [PATCH 05/22] cleaning Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 4 - iOSClient/GUI/Lucid Banner/BannerView.swift | 1 - .../Collection Common/Cell/NCGridCell.swift | 240 ++++++- .../Collection Common/Cell/NCListCell.swift | 321 ++++++++- .../Collection Common/Cell/NCPhotoCell.swift | 58 ++ .../NCCollectionViewCommon+CellLayout.swift | 672 ------------------ .../NCCollectionViewCommon+Search.swift | 1 - 7 files changed, 616 insertions(+), 681 deletions(-) delete mode 100644 iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index a81410dbbe..e596212b38 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -728,7 +728,6 @@ F7C30DFE291BD0B80017149B /* NCNetworkingE2EEDelete.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFC291BD0B80017149B /* NCNetworkingE2EEDelete.swift */; }; F7C30E00291BD2610017149B /* NCNetworkingE2EERename.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */; }; F7C30E01291BD2610017149B /* NCNetworkingE2EERename.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */; }; - F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellLayout.swift */; }; F7C687E92D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; F7C687EA2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; F7C687EB2D22BDE5004757BC /* NCManageDatabase+RecommendedFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */; }; @@ -1685,7 +1684,6 @@ F7C30DF9291BCF790017149B /* NCNetworkingE2EECreateFolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EECreateFolder.swift; sourceTree = ""; }; F7C30DFC291BD0B80017149B /* NCNetworkingE2EEDelete.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EEDelete.swift; sourceTree = ""; }; F7C30DFF291BD2610017149B /* NCNetworkingE2EERename.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCNetworkingE2EERename.swift; sourceTree = ""; }; - F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCCollectionViewCommon+CellLayout.swift"; sourceTree = ""; }; F7C687E82D22BD46004757BC /* NCManageDatabase+RecommendedFiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NCManageDatabase+RecommendedFiles.swift"; sourceTree = ""; }; F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerQuickLook.swift; sourceTree = ""; }; F7C9555221F0C4CA0024296E /* NCActivity.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCActivity.storyboard; sourceTree = ""; }; @@ -2479,7 +2477,6 @@ F75FE06B2BB01D0D00A0EFEF /* Cell */, F70D7C3525FFBF81002B9E34 /* NCCollectionViewCommon.swift */, F7CAFE172F164B9200DB35A5 /* NCCollectionViewCommon+CellDelegate.swift */, - F7C49B7D2F3F168000B18F5F /* NCCollectionViewCommon+CellLayout.swift */, F7743A132C33F13A0034F670 /* NCCollectionViewCommon+CollectionViewDataSource.swift */, F74D50342C9855A000BBBF4C /* NCCollectionViewCommon+CollectionViewDataSourcePrefetching.swift */, F7743A112C33F0A20034F670 /* NCCollectionViewCommon+CollectionViewDelegate.swift */, @@ -4511,7 +4508,6 @@ F785EE9D246196DF00B3F945 /* NCNetworkingE2EE.swift in Sources */, F724377B2C10B83E00C7C68D /* NCSharePermissions.swift in Sources */, F317C82E2E844C5300761AEA /* ClientIntegrationUIViewer.swift in Sources */, - F7C49B7E2F3F169600B18F5F /* NCCollectionViewCommon+CellLayout.swift in Sources */, F794E13D2BBBFF2E003693D7 /* NCMainTabBarController.swift in Sources */, F7CBC1252BAC8B0000EC1D55 /* NCSectionFirstHeaderEmptyData.swift in Sources */, F7D4BF3D2CA2E8D800A5E746 /* TOPasscodeKeypadView.m in Sources */, diff --git a/iOSClient/GUI/Lucid Banner/BannerView.swift b/iOSClient/GUI/Lucid Banner/BannerView.swift index a6815a88ed..90ad6db9c8 100644 --- a/iOSClient/GUI/Lucid Banner/BannerView.swift +++ b/iOSClient/GUI/Lucid Banner/BannerView.swift @@ -393,4 +393,3 @@ struct MessageBannerView: View { .padding() } } - diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 1384416135..d2174fbc91 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -2,7 +2,10 @@ // SPDX-FileCopyrightText: 2018 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later +import Foundation import UIKit +import NextcloudKit +import RealmSwift protocol NCGridCellDelegate: AnyObject { func onMenuIntent(with metadata: tableMetadata?) @@ -29,7 +32,6 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } - var previewImageView: UIImageView? { get { return imageItem } set { imageItem = newValue } @@ -208,3 +210,239 @@ class NCGridLayout: UICollectionViewFlowLayout { return proposedContentOffset } } + +extension NCCollectionViewCommon { + func gridCell(cell: NCGridCell, indexPath: IndexPath, metadata: tableMetadata) -> NCGridCell { + var isShare = false + var isMounted = false + var a11yValues: [String] = [] + let ext = global.getSizeExtension(column: self.numberOfColumns) + let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) + + // CONTENT MODE + cell.previewImageView?.layer.borderWidth = 0 + + if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { + cell.previewImageView?.contentMode = .scaleAspectFill + } else { + cell.previewImageView?.contentMode = .scaleAspectFit + } + + guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { + return cell + } + + if metadataFolder != nil { + isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) + isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) + } + + if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { + cell.labelSubinfo.isHidden = false + cell.labelInfo.text = metadata.sessionError + } else { + cell.labelSubinfo.isHidden = false + cell.writeInfoDateSize(date: metadata.date, size: metadata.size) + } + + cell.labelTitle.text = metadata.fileNameView + + // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { + if metadata.ownerId != metadata.userId { + a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName) + } + + if metadata.directory { + let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) + + if metadata.e2eEncrypted { + cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) + } else if isShare { + cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { + cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) + } else if metadata.mountType == "group" { + cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) + } else if isMounted { + cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) + } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { + cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + } else { + cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) + } + + // Local image: offline + metadata.isOffline = tblDirectory?.offline ?? false + + if metadata.isOffline { + cell.imageLocal.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } + + // color folder + cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + + } else { + let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + + if metadata.hasPreviewBorder { + cell.previewImageView?.layer.borderWidth = 0.2 + cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor + } + + if metadata.name == global.appName { + if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { + cell.previewImageView?.image = image + } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { + cell.previewImageView?.image = image + } + + if cell.previewImageView?.image == nil { + if metadata.iconName.isEmpty { + cell.previewImageView?.image = NCImageCache.shared.getImageFile() + } else { + cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + } + } + } else { + // APP NAME - UNIFIED SEARCH + switch metadata.iconName { + case let str where str.contains("contacts"): + cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("conversation"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("calendar"): + cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("deck"): + cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("mail"): + cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("talk"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("confirm"): + cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("pages"): + cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + default: + cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + } + if !metadata.iconUrl.isEmpty { + if let ownerId = getAvatarFromIconUrl(metadata: metadata) { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.previewImageView?.image = image + } else { + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.previewImageView?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) + } + } + } + } + } + } + + // Local image: offline + metadata.isOffline = tableLocalFile?.offline ?? false + + if metadata.isOffline { + a11yValues.append(NSLocalizedString("_offline_", comment: "")) + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } else if utilityFileSystem.fileProviderStorageExists(metadata) { + cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + } + } + + // image Favorite + if metadata.favorite { + cell.imageFavorite?.image = imageCache.getImageFavorite() + a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) + } + + // Button More + if metadata.lock == true { + cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) + a11yValues.append(String(format: NSLocalizedString("_locked_by_", comment: ""), metadata.lockOwnerDisplayName)) + } else { + cell.setButtonMore(image: imageCache.getImageButtonMore()) + } + + // Status + if metadata.isLivePhoto { + cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) + } else if metadata.isVideo { + cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + } + + switch metadata.status { + case global.metadataStatusWaitCreateFolder: + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + case global.metadataStatusWaitFavorite: + cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + case global.metadataStatusWaitCopy: + cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") + case global.metadataStatusWaitMove: + cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") + case global.metadataStatusWaitRename: + cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") + case global.metadataStatusWaitDownload: + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloading: + cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloadError, global.metadataStatusUploadError: + cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + default: + break + } + + // URL + if metadata.classFile == NKTypeClassFile.url.rawValue { + cell.imageLocal?.image = nil + cell.hideButtonMore(true) + } + + // Edit mode + if fileSelect.contains(metadata.ocId) { + cell.selected(true, isEditMode: isEditMode) + a11yValues.append(NSLocalizedString("_selected_", comment: "")) + } else { + cell.selected(false, isEditMode: isEditMode) + } + + // Accessibility + cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo?.text ?? "") + (cell.labelSubinfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) + + // Color string find in search + cell.labelTitle?.textColor = NCBrandColor.shared.textColor + cell.labelTitle?.font = .systemFont(ofSize: 15) + + // Hide buttons + if metadata.name != global.appName { + cell.hideButtonMore(true) + } + + cell.setIconOutlines() + + // Obligatory here, at the end !! + cell.metadata = metadata + + return cell + } +} diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index d9cdee8f9e..be17e4bc7d 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -2,7 +2,10 @@ // SPDX-FileCopyrightText: 2018 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later +import Foundation import UIKit +import NextcloudKit +import RealmSwift protocol NCListCellDelegate: AnyObject { func onMenuIntent(with metadata: tableMetadata?) @@ -47,8 +50,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto get { return imageItem } set { imageItem = newValue } } - - + override var accessibilityIdentifier: String? { get { super.accessibilityIdentifier @@ -365,3 +367,318 @@ class BidiFilenameLabel: UILabel { return result } } + +#if !EXTENSION +extension NCCollectionViewCommon { + func listCell(cell: NCListCell, indexPath: IndexPath, metadata: tableMetadata) -> NCListCell { + defer { + let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() + if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { + cell.hideButtonShare(true) + } + } + var isShare = false + var isMounted = false + var a11yValues: [String] = [] + let ext = global.getSizeExtension(column: self.numberOfColumns) + let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) + + // CONTENT MODE + cell.avatarImageView?.contentMode = .center + cell.previewImageView?.layer.borderWidth = 0 + + if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { + cell.previewImageView?.contentMode = .scaleAspectFill + } else { + cell.previewImageView?.contentMode = .scaleAspectFit + } + + guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { + return cell + } + + if metadataFolder != nil { + isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) + isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) + } + + if isSearchingMode { + if metadata.name == global.appName { + cell.labelInfo?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) + } else { + cell.labelInfo?.text = metadata.subline + } + cell.labelSubinfo?.isHidden = true + } else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { + cell.labelSubinfo?.isHidden = false + cell.labelInfo?.text = metadata.sessionError + } else { + cell.labelSubinfo?.isHidden = false + cell.writeInfoDateSize(date: metadata.date, size: metadata.size) + } + + cell.labelTitle?.text = metadata.fileNameView + + // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { + if metadata.ownerId != metadata.userId { + a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName) + } + + if metadata.directory { + let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) + + if metadata.e2eEncrypted { + cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) + } else if isShare { + cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { + cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) + } else if metadata.mountType == "group" { + cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) + } else if isMounted { + cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) + } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { + cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + } else { + cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) + } + + // Local image: offline + metadata.isOffline = tblDirectory?.offline ?? false + + if metadata.isOffline { + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } + + // color folder + cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + + } else { + let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + + if metadata.hasPreviewBorder { + cell.previewImageView?.layer.borderWidth = 0.2 + cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor + } + + if metadata.name == global.appName { + if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { + cell.previewImageView?.image = image + } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { + cell.previewImageView?.image = image + } + + if cell.previewImageView?.image == nil { + if metadata.iconName.isEmpty { + cell.previewImageView?.image = NCImageCache.shared.getImageFile() + } else { + cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + } + } + } else { + // APP NAME - UNIFIED SEARCH + switch metadata.iconName { + case let str where str.contains("contacts"): + cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("conversation"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("calendar"): + cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("deck"): + cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("mail"): + cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("talk"): + cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("confirm"): + cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("pages"): + cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + default: + cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + } + if !metadata.iconUrl.isEmpty { + if let ownerId = getAvatarFromIconUrl(metadata: metadata) { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.previewImageView?.image = image + } else { + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.previewImageView?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) + } + } + } + } + } + } + + // Local image: offline + metadata.isOffline = tableLocalFile?.offline ?? false + + if metadata.isOffline { + a11yValues.append(NSLocalizedString("_offline_", comment: "")) + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } else if utilityFileSystem.fileProviderStorageExists(metadata) { + cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + } + } + + // image Favorite + if metadata.favorite { + cell.imageFavorite?.image = imageCache.getImageFavorite() + a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) + } + + // Share image + if isShare { + cell.imageShared?.image = imageCache.getImageShared() + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.imageShared?.image = imageCache.getImageShareByLink()) : + (cell.imageShared?.image = imageCache.getImageShared()) + } else { + cell.imageShared?.image = imageCache.getImageCanShare() + } + + // Button More + if metadata.lock == true { + cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) + a11yValues.append(String(format: NSLocalizedString("_locked_by_", comment: ""), metadata.lockOwnerDisplayName)) + } else { + cell.setButtonMore(image: imageCache.getImageButtonMore()) + } + + // Status + if metadata.isLivePhoto { + cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) + } else if metadata.isVideo { + cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + } + + switch metadata.status { + case global.metadataStatusWaitCreateFolder: + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + case global.metadataStatusWaitFavorite: + cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + case global.metadataStatusWaitCopy: + cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") + case global.metadataStatusWaitMove: + cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") + case global.metadataStatusWaitRename: + cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") + case global.metadataStatusWaitDownload: + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloading: + cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloadError, global.metadataStatusUploadError: + cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + default: + break + } + + // AVATAR + if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = image + } else { + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.avatarImageView?.contentMode = .scaleAspectFill + cell.avatarImageView?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: self.collectionView)) + } + } + } + } + + // URL + if metadata.classFile == NKTypeClassFile.url.rawValue { + cell.imageLocal?.image = nil + cell.hideButtonShare(true) + cell.hideButtonMore(true) + } + + // Separator + if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { + cell.separator?.isHidden = true + } else { + cell.separator?.isHidden = false + } + + // Edit mode + if fileSelect.contains(metadata.ocId) { + cell.selected(true, isEditMode: isEditMode) + a11yValues.append(NSLocalizedString("_selected_", comment: "")) + } else { + cell.selected(false, isEditMode: isEditMode) + } + + // Accessibility + cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo?.text ?? "") + (cell.labelSubinfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) + + // Color string find in search + cell.labelTitle?.textColor = NCBrandColor.shared.textColor + cell.labelTitle?.font = .systemFont(ofSize: 15) + + if isSearchingMode, + let searchResultStore, + let title = cell.labelTitle?.text { + let longestWordRange = (title.lowercased() as NSString).range(of: searchResultStore) + let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) + attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) + cell.labelTitle?.attributedText = attributedString + } + + // TAGS + cell.setTags(tags: Array(metadata.tags)) + + // SearchingMode - TAG Separator Hidden + if isSearchingMode { + cell.labelInfoSeparator.isHidden = true + } + + // Hide buttons + if metadata.name != global.appName { + cell.titleInfoTrailingFull() + cell.hideButtonShare(true) + cell.hideButtonMore(true) + } + + cell.setIconOutlines() + + // Obligatory here, at the end !! + cell.metadata = metadata + + return cell + } +} +#endif diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index 5da47dafee..ef9c820dd1 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -103,3 +103,61 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt accessibilityValue = value } } + +extension NCCollectionViewCommon { + // MARK: - LAYOUT PHOTO + // + func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata) -> NCPhotoCell { + let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) + let ext = global.getSizeExtension(column: self.numberOfColumns) + + cell.metadata = metadata + // cell.hideButtonMore(true) NO MORE USED + cell.hideImageStatus(true) + + // Image + // + if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { + cell.previewImageView?.image = image + cell.previewImageView?.contentMode = .scaleAspectFill + } else { + if isPinchGestureActive || ext == global.previewExt512 || ext == global.previewExt1024 { + cell.previewImageView?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) + } + + DispatchQueue.global(qos: .userInteractive).async { + let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) + if let image { + self.imageCache.addImageCache(ocId: metadata.ocId, etag: metadata.etag, image: image, ext: ext, cost: indexPath.row) + DispatchQueue.main.async { + cell.previewImageView?.image = image + cell.previewImageView?.contentMode = .scaleAspectFill + } + } else { + DispatchQueue.main.async { + cell.previewImageView?.contentMode = .scaleAspectFit + if metadata.iconName.isEmpty { + cell.previewImageView?.image = NCImageCache.shared.getImageFile() + } else { + cell.previewImageView?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + } + } + } + } + } + + // Edit mode + // + if fileSelect.contains(metadata.ocId) { + cell.selected(true, isEditMode: isEditMode) + } else { + cell.selected(false, isEditMode: isEditMode) + } + + if width > 100 { + cell.hideImageStatus(false) + } + + return cell + } +} diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift deleted file mode 100644 index 003ace9ffd..0000000000 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellLayout.swift +++ /dev/null @@ -1,672 +0,0 @@ -// SPDX-FileCopyrightText: Nextcloud GmbH -// SPDX-FileCopyrightText: 2026 Marino Faggiana -// SPDX-License-Identifier: GPL-3.0-or-later - -import Foundation -import UIKit -import NextcloudKit -import RealmSwift - -extension NCCollectionViewCommon { - // MARK: - LAYOUT PHOTO - // - internal func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata) -> NCPhotoCell { - let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) - let ext = global.getSizeExtension(column: self.numberOfColumns) - - cell.metadata = metadata - // cell.hideButtonMore(true) NO MORE USED - cell.hideImageStatus(true) - - // Image - // - if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - - cell.previewImageView?.image = image - cell.previewImageView?.contentMode = .scaleAspectFill - - } else { - - if isPinchGestureActive || ext == global.previewExt512 || ext == global.previewExt1024 { - cell.previewImageView?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) - } - - DispatchQueue.global(qos: .userInteractive).async { - let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) - if let image { - self.imageCache.addImageCache(ocId: metadata.ocId, etag: metadata.etag, image: image, ext: ext, cost: indexPath.row) - DispatchQueue.main.async { - cell.previewImageView?.image = image - cell.previewImageView?.contentMode = .scaleAspectFill - } - } else { - DispatchQueue.main.async { - cell.previewImageView?.contentMode = .scaleAspectFit - if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() - } else { - cell.previewImageView?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) - } - } - } - } - } - - // Edit mode - // - if fileSelect.contains(metadata.ocId) { - cell.selected(true, isEditMode: isEditMode) - } else { - cell.selected(false, isEditMode: isEditMode) - } - - if width > 100 { - // cell.hideButtonMore(false) NO MORE USED - cell.hideImageStatus(false) - } - - return cell - } - - // MARK: - LAYOUT GRID - // - internal func gridCell(cell: NCGridCell, indexPath: IndexPath, metadata: tableMetadata) -> NCGridCell { - var isShare = false - var isMounted = false - var a11yValues: [String] = [] - let ext = global.getSizeExtension(column: self.numberOfColumns) - let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) - - // CONTENT MODE - cell.avatarImageView?.contentMode = .center - cell.previewImageView?.layer.borderWidth = 0 - - if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { - cell.previewImageView?.contentMode = .scaleAspectFill - } else { - cell.previewImageView?.contentMode = .scaleAspectFit - } - - guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { - return cell - } - - if metadataFolder != nil { - isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) - isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) - } - - if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { - cell.labelSubinfo?.isHidden = false - cell.labelInfo?.text = metadata.sessionError - } else { - cell.labelSubinfo?.isHidden = false - cell.writeInfoDateSize(date: metadata.date, size: metadata.size) - } - - cell.labelTitle?.text = metadata.fileNameView - - // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { - if metadata.ownerId != metadata.userId { - a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName) - } - - if metadata.directory { - let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) - - if metadata.e2eEncrypted { - cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) - } else if isShare { - cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) - } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) - } else if metadata.mountType == "group" { - cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) - } else if isMounted { - cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) - } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) - } else { - cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) - } - - // Local image: offline - metadata.isOffline = tblDirectory?.offline ?? false - - if metadata.isOffline { - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } - - // color folder - cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) - - } else { - let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - - if metadata.hasPreviewBorder { - cell.previewImageView?.layer.borderWidth = 0.2 - cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor - } - - if metadata.name == global.appName { - if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImageView?.image = image - } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImageView?.image = image - } - - if cell.previewImageView?.image == nil { - if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() - } else { - cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) - } - } - } else { - // APP NAME - UNIFIED SEARCH - switch metadata.iconName { - case let str where str.contains("contacts"): - cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("conversation"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("calendar"): - cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("deck"): - cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("mail"): - cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("talk"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("confirm"): - cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("pages"): - cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) - default: - cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) - } - if !metadata.iconUrl.isEmpty { - if let ownerId = getAvatarFromIconUrl(metadata: metadata) { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImageView?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.previewImageView?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) - } - } - } - } - } - } - - // Local image: offline - metadata.isOffline = tableLocalFile?.offline ?? false - - if metadata.isOffline { - a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) - } - } - - // image Favorite - if metadata.favorite { - cell.imageFavorite?.image = imageCache.getImageFavorite() - a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) - } - - // Button More - if metadata.lock == true { - cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) - a11yValues.append(String(format: NSLocalizedString("_locked_by_", comment: ""), metadata.lockOwnerDisplayName)) - } else { - cell.setButtonMore(image: imageCache.getImageButtonMore()) - } - - // Status - if metadata.isLivePhoto { - cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) - a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) - } else if metadata.isVideo { - cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) - } - - switch metadata.status { - case global.metadataStatusWaitCreateFolder: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") - case global.metadataStatusWaitFavorite: - cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") - case global.metadataStatusWaitCopy: - cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") - case global.metadataStatusWaitMove: - cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") - case global.metadataStatusWaitRename: - cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") - case global.metadataStatusWaitDownload: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloading: - cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) - default: - break - } - - // AVATAR - if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: self.collectionView)) - } - } - } - } - - // URL - if metadata.classFile == NKTypeClassFile.url.rawValue { - cell.imageLocal?.image = nil - cell.hideButtonMore(true) - } - - // Edit mode - if fileSelect.contains(metadata.ocId) { - cell.selected(true, isEditMode: isEditMode) - a11yValues.append(NSLocalizedString("_selected_", comment: "")) - } else { - cell.selected(false, isEditMode: isEditMode) - } - - // Accessibility - cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo?.text ?? "") + (cell.labelSubinfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) - - // Color string find in search - cell.labelTitle?.textColor = NCBrandColor.shared.textColor - cell.labelTitle?.font = .systemFont(ofSize: 15) - - // Layout photo - if isLayoutPhoto { - let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) - - cell.hideImageFavorite(false) - cell.hideImageLocal(false) - cell.hideImageItem(false) - cell.hideButtonMore(false) - cell.hideLabelInfo(false) - cell.hideLabelSubinfo(false) - cell.hideImageStatus(false) - cell.labelTitle?.font = UIFont.systemFont(ofSize: 15) - - if width < 120 { - cell.hideImageFavorite(true) - cell.hideImageLocal(true) - cell.labelTitle?.font = UIFont.systemFont(ofSize: 10) - if width < 100 { - cell.hideImageItem(true) - cell.hideButtonMore(true) - cell.hideLabelInfo(true) - cell.hideLabelSubinfo(true) - cell.hideImageStatus(true) - } - } - } - - // Hide buttons - if metadata.name != global.appName { - cell.hideButtonMore(true) - } - - cell.setIconOutlines() - - // Obligatory here, at the end !! - cell.metadata = metadata - - return cell - } - - // MARK: - LAYOUT LIST - // - internal func listCell(cell: NCListCell, indexPath: IndexPath, metadata: tableMetadata) -> NCListCell { - defer { - let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() - if !metadata.isSharable() || (!capabilities.fileSharingApiEnabled && !capabilities.filesComments && capabilities.activity.isEmpty) { - cell.hideButtonShare(true) - } - } - var isShare = false - var isMounted = false - var a11yValues: [String] = [] - let ext = global.getSizeExtension(column: self.numberOfColumns) - let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) - - // CONTENT MODE - cell.avatarImageView?.contentMode = .center - cell.previewImageView?.layer.borderWidth = 0 - - if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { - cell.previewImageView?.contentMode = .scaleAspectFill - } else { - cell.previewImageView?.contentMode = .scaleAspectFit - } - - guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { - return cell - } - - if metadataFolder != nil { - isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) - isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) - } - - if isSearchingMode { - if metadata.name == global.appName { - cell.labelInfo?.text = NSLocalizedString("_in_", comment: "") + " " + utilityFileSystem.getPath(path: metadata.path, user: metadata.user) - } else { - cell.labelInfo?.text = metadata.subline - } - cell.labelSubinfo?.isHidden = true - } else if !metadata.sessionError.isEmpty, metadata.status != global.metadataStatusNormal { - cell.labelSubinfo?.isHidden = false - cell.labelInfo?.text = metadata.sessionError - } else { - cell.labelSubinfo?.isHidden = false - cell.writeInfoDateSize(date: metadata.date, size: metadata.size) - } - - cell.labelTitle?.text = metadata.fileNameView - - // Accessibility [shared] if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account { - if metadata.ownerId != metadata.userId { - a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName) - } - - if metadata.directory { - let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) - - if metadata.e2eEncrypted { - cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) - } else if isShare { - cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) - } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) - } else if metadata.mountType == "group" { - cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) - } else if isMounted { - cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) - } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) - } else { - cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) - } - - // Local image: offline - metadata.isOffline = tblDirectory?.offline ?? false - - if metadata.isOffline { - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } - - // color folder - cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) - - } else { - let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - - if metadata.hasPreviewBorder { - cell.previewImageView?.layer.borderWidth = 0.2 - cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor - } - - if metadata.name == global.appName { - if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImageView?.image = image - } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImageView?.image = image - } - - if cell.previewImageView?.image == nil { - if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() - } else { - cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) - } - } - } else { - // APP NAME - UNIFIED SEARCH - switch metadata.iconName { - case let str where str.contains("contacts"): - cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("conversation"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("calendar"): - cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("deck"): - cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("mail"): - cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("talk"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("confirm"): - cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("pages"): - cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) - default: - cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) - } - if !metadata.iconUrl.isEmpty { - if let ownerId = getAvatarFromIconUrl(metadata: metadata) { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImageView?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.previewImageView?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) - } - } - } - } - } - } - - // Local image: offline - metadata.isOffline = tableLocalFile?.offline ?? false - - if metadata.isOffline { - a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) - } - } - - // image Favorite - if metadata.favorite { - cell.imageFavorite?.image = imageCache.getImageFavorite() - a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) - } - - // Share image - if isShare { - cell.imageShared?.image = imageCache.getImageShared() - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.imageShared?.image = imageCache.getImageShareByLink()) : - (cell.imageShared?.image = imageCache.getImageShared()) - } else { - cell.imageShared?.image = imageCache.getImageCanShare() - } - - // Button More - if metadata.lock == true { - cell.setButtonMore(image: imageCache.getImageButtonMoreLock()) - a11yValues.append(String(format: NSLocalizedString("_locked_by_", comment: ""), metadata.lockOwnerDisplayName)) - } else { - cell.setButtonMore(image: imageCache.getImageButtonMore()) - } - - // Status - if metadata.isLivePhoto { - cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) - a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) - } else if metadata.isVideo { - cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) - } - - switch metadata.status { - case global.metadataStatusWaitCreateFolder: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") - case global.metadataStatusWaitFavorite: - cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") - case global.metadataStatusWaitCopy: - cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") - case global.metadataStatusWaitMove: - cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") - case global.metadataStatusWaitRename: - cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") - case global.metadataStatusWaitDownload: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloading: - cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) - default: - break - } - - // AVATAR - if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: metadata.ownerId, fileName: fileName, account: metadata.account, view: self.collectionView)) - } - } - } - } - - // URL - if metadata.classFile == NKTypeClassFile.url.rawValue { - cell.imageLocal?.image = nil - cell.hideButtonShare(true) - cell.hideButtonMore(true) - } - - // Separator - if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearchingMode { - cell.separator?.isHidden = true - } else { - cell.separator?.isHidden = false - } - - // Edit mode - if fileSelect.contains(metadata.ocId) { - cell.selected(true, isEditMode: isEditMode) - a11yValues.append(NSLocalizedString("_selected_", comment: "")) - } else { - cell.selected(false, isEditMode: isEditMode) - } - - // Accessibility - cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo?.text ?? "") + (cell.labelSubinfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) - - // Color string find in search - cell.labelTitle?.textColor = NCBrandColor.shared.textColor - cell.labelTitle?.font = .systemFont(ofSize: 15) - - if isSearchingMode, - let searchResultStore, - let title = cell.labelTitle?.text { - let longestWordRange = (title.lowercased() as NSString).range(of: searchResultStore) - let attributedString = NSMutableAttributedString(string: title, attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)]) - attributedString.setAttributes([NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor.systemBlue], range: longestWordRange) - cell.labelTitle?.attributedText = attributedString - } - - // TAGS - cell.setTags(tags: Array(metadata.tags)) - - // SearchingMode - TAG Separator Hidden - if isSearchingMode { - cell.labelInfoSeparator.isHidden = true - } - - // Hide buttons - if metadata.name != global.appName { - cell.titleInfoTrailingFull() - cell.hideButtonShare(true) - cell.hideButtonMore(true) - } - - cell.setIconOutlines() - - // Obligatory here, at the end !! - cell.metadata = metadata - - return cell - } -} diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+Search.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+Search.swift index 10a8c63438..799e0e6b77 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+Search.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+Search.swift @@ -327,4 +327,3 @@ extension NCCollectionViewCommon { return metadata } } - From deeba28f823550156ee24ca88658c90b7f5e5847 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 12:42:20 +0100 Subject: [PATCH 06/22] clear Signed-off-by: Marino Faggiana --- iOSClient/Activity/NCActivity.swift | 8 +- .../Activity/NCActivityTableViewCell.swift | 2 +- .../Cell/NCCellProtocol.swift | 8 +- .../Collection Common/Cell/NCGridCell.swift | 68 +++++++-------- .../Collection Common/Cell/NCListCell.swift | 84 +++++++++---------- .../Collection Common/Cell/NCPhotoCell.swift | 18 ++-- .../NCCollectionViewDownloadThumbnail.swift | 12 +-- .../Networking/NCNetworking+WebDAV.swift | 14 ++-- iOSClient/Notification/NCNotification.swift | 6 +- iOSClient/Select/NCSelect.swift | 6 +- iOSClient/Share/NCShareCommentsCell.swift | 2 +- iOSClient/Share/NCShareUserCell.swift | 4 +- 12 files changed, 116 insertions(+), 116 deletions(-) diff --git a/iOSClient/Activity/NCActivity.swift b/iOSClient/Activity/NCActivity.swift index 9959cf54c6..ac0cb3fc0d 100644 --- a/iOSClient/Activity/NCActivity.swift +++ b/iOSClient/Activity/NCActivity.swift @@ -223,9 +223,9 @@ extension NCActivity: UITableViewDataSource { let results = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) if results.image == nil { - cell.avatarImageView?.image = utility.loadUserImage(for: comment.actorId, displayName: comment.actorDisplayName, urlBase: NCSession.shared.getSession(account: account).urlBase) + cell.avatarImage?.image = utility.loadUserImage(for: comment.actorId, displayName: comment.actorDisplayName, urlBase: NCSession.shared.getSession(account: account).urlBase) } else { - cell.avatarImageView?.image = results.image + cell.avatarImage?.image = results.image } if let tblAvatar = results.tblAvatar, @@ -296,9 +296,9 @@ extension NCActivity: UITableViewDataSource { let results = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) if results.image == nil { - cell.avatarImageView?.image = utility.loadUserImage(for: activity.user, displayName: nil, urlBase: session.urlBase) + cell.avatarImage?.image = utility.loadUserImage(for: activity.user, displayName: nil, urlBase: session.urlBase) } else { - cell.avatarImageView?.image = results.image + cell.avatarImage?.image = results.image } if !(results.tblAvatar?.loaded ?? false), diff --git a/iOSClient/Activity/NCActivityTableViewCell.swift b/iOSClient/Activity/NCActivityTableViewCell.swift index 67df203544..88126d3e91 100644 --- a/iOSClient/Activity/NCActivityTableViewCell.swift +++ b/iOSClient/Activity/NCActivityTableViewCell.swift @@ -36,7 +36,7 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol { get { return index } set { index = newValue } } - var avatarImageView: UIImageView? { + var avatarImage: UIImageView? { return avatar } var fileUser: String? { diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index 1e7407e898..0b95db93ac 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -6,8 +6,8 @@ import UIKit protocol NCCellProtocol { var metadata: tableMetadata? {get set } - var avatarImageView: UIImageView? { get } - var previewImageView: UIImageView? { get set } + var avatarImage: UIImageView? { get } + var previewImage: UIImageView? { get set } func hideButtonMore(_ status: Bool) func hideImageStatus(_ status: Bool) @@ -18,10 +18,10 @@ extension NCCellProtocol { get { return nil } set {} } - var avatarImageView: UIImageView? { + var avatarImage: UIImageView? { return nil } - var previewImageView: UIImageView? { + var previewImage: UIImageView? { get { return nil } set {} } diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index d2174fbc91..dec77aeebd 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -32,7 +32,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } - var previewImageView: UIImageView? { + var previewImage: UIImageView? { get { return imageItem } set { imageItem = newValue } } @@ -220,12 +220,12 @@ extension NCCollectionViewCommon { let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) // CONTENT MODE - cell.previewImageView?.layer.borderWidth = 0 + cell.previewImage?.layer.borderWidth = 0 if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { - cell.previewImageView?.contentMode = .scaleAspectFill + cell.previewImage?.contentMode = .scaleAspectFill } else { - cell.previewImageView?.contentMode = .scaleAspectFit + cell.previewImage?.contentMode = .scaleAspectFit } guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { @@ -256,23 +256,23 @@ extension NCCollectionViewCommon { let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) if metadata.e2eEncrypted { - cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderEncrypted(account: metadata.account) } else if isShare { - cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account) } else if !metadata.shareType.isEmpty { metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + (cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account) } else if metadata.mountType == "group" { - cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderGroup(account: metadata.account) } else if isMounted { - cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderExternal(account: metadata.account) } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) } else { - cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) + cell.previewImage?.image = imageCache.getFolder(account: metadata.account) } // Local image: offline @@ -283,69 +283,69 @@ extension NCCollectionViewCommon { } // color folder - cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) } else { let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) if metadata.hasPreviewBorder { - cell.previewImageView?.layer.borderWidth = 0.2 - cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor + cell.previewImage?.layer.borderWidth = 0.2 + cell.previewImage?.layer.borderColor = UIColor.lightGray.cgColor } if metadata.name == global.appName { if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImageView?.image = image + cell.previewImage?.image = image } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImageView?.image = image + cell.previewImage?.image = image } - if cell.previewImageView?.image == nil { + if cell.previewImage?.image == nil { if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() + cell.previewImage?.image = NCImageCache.shared.getImageFile() } else { - cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + cell.previewImage?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } } } else { // APP NAME - UNIFIED SEARCH switch metadata.iconName { case let str where str.contains("contacts"): - cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("conversation"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) case let str where str.contains("calendar"): - cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("deck"): - cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("mail"): - cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("talk"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) case let str where str.contains("confirm"): - cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("pages"): - cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) default: - cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) } if !metadata.iconUrl.isEmpty { if let ownerId = getAvatarFromIconUrl(metadata: metadata) { let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImageView?.image = image + cell.previewImage?.image = image } else { self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in if let image { - cell.previewImageView?.image = image + cell.previewImage?.image = image NCImageCache.shared.addImageCache(image: image, key: fileName) } else { - cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + cell.previewImage?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) } if !(tblAvatar?.loaded ?? false), self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImage: true)) } } } diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index be17e4bc7d..b8f1ca11f1 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -43,10 +43,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } } - var avatarImageView: UIImageView? { + var avatarImage: UIImageView? { return imageShared } - var previewImageView: UIImageView? { + var previewImage: UIImageView? { get { return imageItem } set { imageItem = newValue } } @@ -384,13 +384,13 @@ extension NCCollectionViewCommon { let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) // CONTENT MODE - cell.avatarImageView?.contentMode = .center - cell.previewImageView?.layer.borderWidth = 0 + cell.avatarImage?.contentMode = .center + cell.previewImage?.layer.borderWidth = 0 if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { - cell.previewImageView?.contentMode = .scaleAspectFill + cell.previewImage?.contentMode = .scaleAspectFill } else { - cell.previewImageView?.contentMode = .scaleAspectFit + cell.previewImage?.contentMode = .scaleAspectFit } guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { @@ -428,23 +428,23 @@ extension NCCollectionViewCommon { let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) if metadata.e2eEncrypted { - cell.previewImageView?.image = imageCache.getFolderEncrypted(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderEncrypted(account: metadata.account) } else if isShare { - cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account) } else if !metadata.shareType.isEmpty { metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImageView?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + (cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImageView?.image = imageCache.getFolderPublic(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account) } else if metadata.mountType == "group" { - cell.previewImageView?.image = imageCache.getFolderGroup(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderGroup(account: metadata.account) } else if isMounted { - cell.previewImageView?.image = imageCache.getFolderExternal(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderExternal(account: metadata.account) } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImageView?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + cell.previewImage?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) } else { - cell.previewImageView?.image = imageCache.getFolder(account: metadata.account) + cell.previewImage?.image = imageCache.getFolder(account: metadata.account) } // Local image: offline @@ -455,69 +455,69 @@ extension NCCollectionViewCommon { } // color folder - cell.previewImageView?.image = cell.previewImageView?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) } else { let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) if metadata.hasPreviewBorder { - cell.previewImageView?.layer.borderWidth = 0.2 - cell.previewImageView?.layer.borderColor = UIColor.lightGray.cgColor + cell.previewImage?.layer.borderWidth = 0.2 + cell.previewImage?.layer.borderColor = UIColor.lightGray.cgColor } if metadata.name == global.appName { if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImageView?.image = image + cell.previewImage?.image = image } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImageView?.image = image + cell.previewImage?.image = image } - if cell.previewImageView?.image == nil { + if cell.previewImage?.image == nil { if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() + cell.previewImage?.image = NCImageCache.shared.getImageFile() } else { - cell.previewImageView?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + cell.previewImage?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } } } else { // APP NAME - UNIFIED SEARCH switch metadata.iconName { case let str where str.contains("contacts"): - cell.previewImageView?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("conversation"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) case let str where str.contains("calendar"): - cell.previewImageView?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("deck"): - cell.previewImageView?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("mail"): - cell.previewImageView?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("talk"): - cell.previewImageView?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) case let str where str.contains("confirm"): - cell.previewImageView?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("pages"): - cell.previewImageView?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) default: - cell.previewImageView?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImage?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) } if !metadata.iconUrl.isEmpty { if let ownerId = getAvatarFromIconUrl(metadata: metadata) { let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImageView?.image = image + cell.previewImage?.image = image } else { self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in if let image { - cell.previewImageView?.image = image + cell.previewImage?.image = image NCImageCache.shared.addImageCache(image: image, key: fileName) } else { - cell.previewImageView?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + cell.previewImage?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) } if !(tblAvatar?.loaded ?? false), self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImageView: true)) + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImage: true)) } } } @@ -599,17 +599,17 @@ extension NCCollectionViewCommon { if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image + cell.avatarImage?.contentMode = .scaleAspectFill + cell.avatarImage?.image = image } else { self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in if let image { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = image + cell.avatarImage?.contentMode = .scaleAspectFill + cell.avatarImage?.image = image NCImageCache.shared.addImageCache(image: image, key: fileName) } else { - cell.avatarImageView?.contentMode = .scaleAspectFill - cell.avatarImageView?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) + cell.avatarImage?.contentMode = .scaleAspectFill + cell.avatarImage?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) } if !(tblAvatar?.loaded ?? false), diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index ef9c820dd1..098b22069a 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -24,7 +24,7 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt } } - var previewImageView: UIImageView? { + var previewImage: UIImageView? { get { return imageItem } set { imageItem = newValue } } @@ -118,11 +118,11 @@ extension NCCollectionViewCommon { // Image // if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImageView?.image = image - cell.previewImageView?.contentMode = .scaleAspectFill + cell.previewImage?.image = image + cell.previewImage?.contentMode = .scaleAspectFill } else { if isPinchGestureActive || ext == global.previewExt512 || ext == global.previewExt1024 { - cell.previewImageView?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) + cell.previewImage?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) } DispatchQueue.global(qos: .userInteractive).async { @@ -130,16 +130,16 @@ extension NCCollectionViewCommon { if let image { self.imageCache.addImageCache(ocId: metadata.ocId, etag: metadata.etag, image: image, ext: ext, cost: indexPath.row) DispatchQueue.main.async { - cell.previewImageView?.image = image - cell.previewImageView?.contentMode = .scaleAspectFill + cell.previewImage?.image = image + cell.previewImage?.contentMode = .scaleAspectFill } } else { DispatchQueue.main.async { - cell.previewImageView?.contentMode = .scaleAspectFit + cell.previewImage?.contentMode = .scaleAspectFit if metadata.iconName.isEmpty { - cell.previewImageView?.image = NCImageCache.shared.getImageFile() + cell.previewImage?.image = NCImageCache.shared.getImageFile() } else { - cell.previewImageView?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + cell.previewImage?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } } } diff --git a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift index a9651883d1..71f2fbe4cd 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift @@ -43,12 +43,12 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation, @unchecked Sendabl Task { @MainActor in for case let cell as NCCellProtocol in collectionView.visibleCells where cell.metadata?.ocId == self.metadata.ocId { - if let previewImageView = cell.previewImageView { - previewImageView.contentMode = .scaleAspectFill + if let previewImage = cell.previewImage { + previewImage.contentMode = .scaleAspectFill if self.metadata.hasPreviewBorder { - previewImageView.layer.borderWidth = 0.2 - previewImageView.layer.borderColor = UIColor.systemGray3.cgColor + previewImage.layer.borderWidth = 0.2 + previewImage.layer.borderColor = UIColor.systemGray3.cgColor } if let photoCell = (cell as? NCPhotoCell), @@ -58,11 +58,11 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation, @unchecked Sendabl } UIView.transition( - with: previewImageView, + with: previewImage, duration: 0.75, options: .transitionCrossDissolve, animations: { - previewImageView.image = image + previewImage.image = image }, completion: nil ) diff --git a/iOSClient/Networking/NCNetworking+WebDAV.swift b/iOSClient/Networking/NCNetworking+WebDAV.swift index 376b3819ba..0490ae6c11 100644 --- a/iOSClient/Networking/NCNetworking+WebDAV.swift +++ b/iOSClient/Networking/NCNetworking+WebDAV.swift @@ -841,14 +841,14 @@ class NCOperationDownloadAvatar: ConcurrentOperation, @unchecked Sendable { var etag: String? var view: UIView? var account: String - var isPreviewImageView: Bool + var isPreviewImage: Bool - init(user: String, fileName: String, account: String, view: UIView?, isPreviewImageView: Bool = false) { + init(user: String, fileName: String, account: String, view: UIView?, isPreviewImage: Bool = false) { self.user = user self.fileName = fileName self.account = account self.view = view - self.isPreviewImageView = isPreviewImageView + self.isPreviewImage = isPreviewImage self.etag = NCManageDatabase.shared.getTableAvatar(fileName: fileName)?.etag } @@ -882,10 +882,10 @@ class NCOperationDownloadAvatar: ConcurrentOperation, @unchecked Sendable { let visibleCells: [UIView] = (self.view as? UICollectionView)?.visibleCells ?? (self.view as? UITableView)?.visibleCells ?? [] for case let cell as NCCellProtocol in visibleCells { if self.user == cell.metadata?.ownerId { - if self.isPreviewImageView, let previewImageView = cell.previewImageView { - UIView.transition(with: previewImageView, duration: 0.75, options: .transitionCrossDissolve, animations: { previewImageView.image = image}, completion: nil) - } else if let avatarImageView = cell.avatarImageView { - UIView.transition(with: avatarImageView, duration: 0.75, options: .transitionCrossDissolve, animations: { avatarImageView.image = image}, completion: nil) + if self.isPreviewImage, let previewImage = cell.previewImage { + UIView.transition(with: previewImage, duration: 0.75, options: .transitionCrossDissolve, animations: { previewImage.image = image}, completion: nil) + } else if let avatarImage = cell.avatarImage { + UIView.transition(with: avatarImage, duration: 0.75, options: .transitionCrossDissolve, animations: { avatarImage.image = image}, completion: nil) } break } diff --git a/iOSClient/Notification/NCNotification.swift b/iOSClient/Notification/NCNotification.swift index 84fc727b1e..9d670088ab 100644 --- a/iOSClient/Notification/NCNotification.swift +++ b/iOSClient/Notification/NCNotification.swift @@ -142,9 +142,9 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate { let results = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) if results.image == nil { - cell.avatarImageView?.image = utility.loadUserImage(for: user, displayName: json["user"]?["name"].string, urlBase: session.urlBase) + cell.avatarImage?.image = utility.loadUserImage(for: user, displayName: json["user"]?["name"].string, urlBase: session.urlBase) } else { - cell.avatarImageView?.image = results.image + cell.avatarImage?.image = results.image } if !(results.tblAvatar?.loaded ?? false), @@ -378,7 +378,7 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol { get { return index } set { index = newValue } } - var avatarImageView: UIImageView? { + var avatarImage: UIImageView? { return avatar } var fileUser: String? { diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index ff9bfbb213..61e2761ca1 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -337,12 +337,12 @@ extension NCSelect: UICollectionViewDataSource { // Thumbnail if !metadata.directory { if let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: NCGlobal.shared.previewExt512, userId: metadata.userId, urlBase: metadata.urlBase) { - (cell as? NCCellProtocol)?.previewImageView?.image = image + (cell as? NCCellProtocol)?.previewImage?.image = image } else { if metadata.iconName.isEmpty { - (cell as? NCCellProtocol)?.previewImageView?.image = NCImageCache.shared.getImageFile() + (cell as? NCCellProtocol)?.previewImage?.image = NCImageCache.shared.getImageFile() } else { - (cell as? NCCellProtocol)?.previewImageView?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + (cell as? NCCellProtocol)?.previewImage?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } if metadata.hasPreview, metadata.status == NCGlobal.shared.metadataStatusNormal { diff --git a/iOSClient/Share/NCShareCommentsCell.swift b/iOSClient/Share/NCShareCommentsCell.swift index 80952a7684..7da775c97b 100644 --- a/iOSClient/Share/NCShareCommentsCell.swift +++ b/iOSClient/Share/NCShareCommentsCell.swift @@ -44,7 +44,7 @@ class NCShareCommentsCell: UITableViewCell, NCCellProtocol { get { return index } set { index = newValue } } - var avatarImageView: UIImageView? { + var avatarImage: UIImageView? { return imageItem } var fileUser: String? { diff --git a/iOSClient/Share/NCShareUserCell.swift b/iOSClient/Share/NCShareUserCell.swift index ee953deea5..cbaf259d12 100644 --- a/iOSClient/Share/NCShareUserCell.swift +++ b/iOSClient/Share/NCShareUserCell.swift @@ -46,7 +46,7 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol { get { return index } set { index = newValue } } - var avatarImageView: UIImageView? { + var avatarImage: UIImageView? { return imageItem } var fileUser: String? { @@ -187,7 +187,7 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol { get { return index } set { index = newValue } } - var avatarImageView: UIImageView? { + var avatarImage: UIImageView? { return imageItem } var fileUser: String? { From bb12f962649c0a4d774f29324336afbe7443a5a3 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 12:48:57 +0100 Subject: [PATCH 07/22] clean Signed-off-by: Marino Faggiana --- .../Collection Common/Cell/NCGridCell.swift | 34 +++---------------- .../Collection Common/Cell/NCListCell.swift | 2 +- .../Collection Common/Cell/NCPhotoCell.swift | 5 ++- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index dec77aeebd..487886269c 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -27,11 +27,15 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto weak var delegate: NCGridCellDelegate? + // Cell Protocol var metadata: tableMetadata? { didSet { delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } + var avatarImage: UIImageView? { + return nil + } var previewImage: UIImageView? { get { return imageItem } set { imageItem = newValue } @@ -100,31 +104,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto buttonMore.setImage(image, for: .normal) } - func hideImageItem(_ status: Bool) { - imageItem.isHidden = status - } - - func hideImageFavorite(_ status: Bool) { - imageFavorite.isHidden = status - } - - func hideImageStatus(_ status: Bool) { - imageStatus.isHidden = status - } - - func hideImageLocal(_ status: Bool) { - imageLocal.isHidden = status - } - - func hideLabelInfo(_ status: Bool) { - labelInfo.isHidden = status - } - - func hideLabelSubinfo(_ status: Bool) { - labelSubinfo.isHidden = status - } - - func hideButtonMore(_ status: Bool) { + func setButtonMore(_ status: Bool) { buttonMore.isHidden = status } @@ -159,8 +139,6 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto accessibilityLabel = label accessibilityValue = value } - - func setIconOutlines() {} } // MARK: - Grid Layout @@ -438,8 +416,6 @@ extension NCCollectionViewCommon { cell.hideButtonMore(true) } - cell.setIconOutlines() - // Obligatory here, at the end !! cell.metadata = metadata diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index b8f1ca11f1..d488ffa392 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -37,12 +37,12 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto weak var delegate: NCListCellDelegate? + // Cell Protocol var metadata: tableMetadata? { didSet { delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } - var avatarImage: UIImageView? { return imageShared } diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index 098b22069a..df1ee6006b 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -18,12 +18,15 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt weak var delegate: NCPhotoCellDelegate? + // Cell Protocol var metadata: tableMetadata? { didSet { delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } - + var avatarImage: UIImageView? { + return nil + } var previewImage: UIImageView? { get { return imageItem } set { imageItem = newValue } From 56f54b1e119cef074f1e39ec13a1ee383eb43d21 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 13:45:20 +0100 Subject: [PATCH 08/22] cleanr Signed-off-by: Marino Faggiana --- iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift | 3 ++- iOSClient/Main/Collection Common/Cell/NCGridCell.swift | 6 ------ iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift | 5 ----- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index 0b95db93ac..339e5b3812 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -19,7 +19,8 @@ extension NCCellProtocol { set {} } var avatarImage: UIImageView? { - return nil + get { return nil } + set {} } var previewImage: UIImageView? { get { return nil } diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 487886269c..829f5f38ea 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -393,7 +393,6 @@ extension NCCollectionViewCommon { // URL if metadata.classFile == NKTypeClassFile.url.rawValue { cell.imageLocal?.image = nil - cell.hideButtonMore(true) } // Edit mode @@ -411,11 +410,6 @@ extension NCCollectionViewCommon { cell.labelTitle?.textColor = NCBrandColor.shared.textColor cell.labelTitle?.font = .systemFont(ofSize: 15) - // Hide buttons - if metadata.name != global.appName { - cell.hideButtonMore(true) - } - // Obligatory here, at the end !! cell.metadata = metadata diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index df1ee6006b..6458d1774a 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -82,10 +82,6 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt buttonMore.setImage(image, for: .normal) } - func hideButtonMore(_ status: Bool) { - // buttonMore.isHidden = status NO MORE USED - } - func hideImageStatus(_ status: Bool) { imageStatus.isHidden = status } @@ -115,7 +111,6 @@ extension NCCollectionViewCommon { let ext = global.getSizeExtension(column: self.numberOfColumns) cell.metadata = metadata - // cell.hideButtonMore(true) NO MORE USED cell.hideImageStatus(true) // Image From 5a509a81d14d5444cfb115bfa64a2e0357407ef7 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 13:56:01 +0100 Subject: [PATCH 09/22] clean Signed-off-by: Marino Faggiana --- .../Cell/NCCellProtocol.swift | 6 --- .../Collection Common/Cell/NCPhotoCell.swift | 53 +------------------ .../Collection Common/Cell/NCPhotoCell.xib | 31 +---------- .../NCCollectionViewCommon+CellDelegate.swift | 2 +- ...nViewCommon+CollectionViewDataSource.swift | 1 - .../NCCollectionViewDownloadThumbnail.swift | 6 --- iOSClient/Trash/Cell/NCTrashGridCell.swift | 5 -- 7 files changed, 4 insertions(+), 100 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index 339e5b3812..14963076bd 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -8,9 +8,6 @@ protocol NCCellProtocol { var metadata: tableMetadata? {get set } var avatarImage: UIImageView? { get } var previewImage: UIImageView? { get set } - - func hideButtonMore(_ status: Bool) - func hideImageStatus(_ status: Bool) } extension NCCellProtocol { @@ -26,7 +23,4 @@ extension NCCellProtocol { get { return nil } set {} } - - func hideButtonMore(_ status: Bool) {} - func hideImageStatus(_ status: Bool) {} } diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index 6458d1774a..ecaa6c6207 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -4,26 +4,13 @@ import UIKit -protocol NCPhotoCellDelegate: AnyObject { - func onMenuIntent(with metadata: tableMetadata?) - func openContextMenu(with metadata: tableMetadata?, button: UIButton, sender: Any) -} - class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProtocol { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var imageSelect: UIImageView! - @IBOutlet weak var imageStatus: UIImageView! - @IBOutlet weak var buttonMore: UIButton! @IBOutlet weak var imageVisualEffect: UIVisualEffectView! - weak var delegate: NCPhotoCellDelegate? - // Cell Protocol - var metadata: tableMetadata? { - didSet { - delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ - } - } + var metadata: tableMetadata? var avatarImage: UIImageView? { return nil } @@ -32,17 +19,6 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt set { imageItem = newValue } } - override func awakeFromNib() { - super.awakeFromNib() - - let tapObserver = UITapGestureRecognizer(target: self, action: #selector(handleTapObserver(_:))) - tapObserver.cancelsTouchesInView = false - tapObserver.delegate = self - contentView.addGestureRecognizer(tapObserver) - - initCell() - } - override func prepareForReuse() { super.prepareForReuse() initCell() @@ -56,36 +32,14 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt imageItem.image = nil imageSelect.isHidden = true imageSelect.image = NCImageCache.shared.getImageCheckedYes() - imageStatus.image = nil imageVisualEffect.clipsToBounds = true imageVisualEffect.alpha = 0.5 - - buttonMore.isHidden = true - buttonMore.menu = nil - buttonMore.showsMenuAsPrimaryAction = true - contentView.bringSubviewToFront(buttonMore) } override func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? { return nil } - @objc private func handleTapObserver(_ g: UITapGestureRecognizer) { - let location = g.location(in: contentView) - - if buttonMore.frame.contains(location) { - delegate?.onMenuIntent(with: metadata) - } - } - - func setButtonMore(image: UIImage) { - buttonMore.setImage(image, for: .normal) - } - - func hideImageStatus(_ status: Bool) { - imageStatus.isHidden = status - } - func selected(_ status: Bool, isEditMode: Bool) { if status { imageSelect.isHidden = false @@ -111,7 +65,6 @@ extension NCCollectionViewCommon { let ext = global.getSizeExtension(column: self.numberOfColumns) cell.metadata = metadata - cell.hideImageStatus(true) // Image // @@ -152,10 +105,6 @@ extension NCCollectionViewCommon { cell.selected(false, isEditMode: isEditMode) } - if width > 100 { - cell.hideImageStatus(false) - } - return cell } } diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.xib b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.xib index 1e47d12444..40878baeef 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.xib +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.xib @@ -1,8 +1,8 @@ - + - + @@ -28,13 +28,6 @@ - - - - - - - @@ -42,23 +35,11 @@ - - - @@ -66,29 +47,21 @@ - - - - - - - - diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellDelegate.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellDelegate.swift index 7b799e9ef4..d991fb9ec6 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellDelegate.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CellDelegate.swift @@ -1,4 +1,4 @@ -extension NCCollectionViewCommon: NCListCellDelegate, NCGridCellDelegate, NCPhotoCellDelegate { +extension NCCollectionViewCommon: NCListCellDelegate, NCGridCellDelegate { func openContextMenu(with metadata: tableMetadata?, button: UIButton, sender: Any) { Task { guard let metadata else { return } diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift index aeb2f0ec5e..da6923e610 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon+CollectionViewDataSource.swift @@ -67,7 +67,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource { if isLayoutPhoto { if metadata.isImageOrVideo { let photoCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "photoCell", for: indexPath) as? NCPhotoCell)! - photoCell.delegate = self return self.photoCell(cell: photoCell, indexPath: indexPath, metadata: metadata) } else { let gridCell = (collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell)! diff --git a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift index 71f2fbe4cd..3dccfa45d5 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift @@ -51,12 +51,6 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation, @unchecked Sendabl previewImage.layer.borderColor = UIColor.systemGray3.cgColor } - if let photoCell = (cell as? NCPhotoCell), - photoCell.bounds.size.width > 100 { - cell.hideButtonMore(false) - cell.hideImageStatus(false) - } - UIView.transition( with: previewImage, duration: 0.75, diff --git a/iOSClient/Trash/Cell/NCTrashGridCell.swift b/iOSClient/Trash/Cell/NCTrashGridCell.swift index 0fae0620f7..5c03bbb5b4 100644 --- a/iOSClient/Trash/Cell/NCTrashGridCell.swift +++ b/iOSClient/Trash/Cell/NCTrashGridCell.swift @@ -28,7 +28,6 @@ protocol NCTrashGridCellDelegate: AnyObject { } class NCTrashGridCell: UICollectionViewCell, NCTrashCellProtocol { - @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var imageSelect: UIImageView! @IBOutlet weak var labelTitle: UILabel! @@ -93,10 +92,6 @@ class NCTrashGridCell: UICollectionViewCell, NCTrashCellProtocol { setA11yActions() } - func hideButtonMore(_ status: Bool) { - buttonMore.isHidden = status - } - func selected(_ status: Bool, isEditMode: Bool, account: String) { if isEditMode { buttonMore.isHidden = true From 43a5fef4eb2885076b9a975302b494eb98a53b59 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Fri, 13 Feb 2026 14:28:10 +0100 Subject: [PATCH 10/22] clean Signed-off-by: Marino Faggiana --- Share/NCShareExtension+DataSource.swift | 4 +- .../Account Request/NCShareAccounts.swift | 1 - .../Cell/NCCellProtocol.swift | 127 ++++++++++++++++++ .../Collection Common/Cell/NCGridCell.swift | 116 +--------------- .../Collection Common/Cell/NCListCell.swift | 113 +--------------- .../Collection Common/Cell/NCPhotoCell.swift | 4 - iOSClient/Select/NCSelect.swift | 6 +- 7 files changed, 138 insertions(+), 233 deletions(-) diff --git a/Share/NCShareExtension+DataSource.swift b/Share/NCShareExtension+DataSource.swift index f45ca5e0a0..5cb80c8e74 100644 --- a/Share/NCShareExtension+DataSource.swift +++ b/Share/NCShareExtension+DataSource.swift @@ -86,7 +86,7 @@ extension NCShareExtension: UICollectionViewDataSource { cell.labelTitle.textColor = NCBrandColor.shared.textColor cell.imageSelect.image = nil cell.imageStatus.image = nil - cell.imageLocal.image = nil + cell.imageLocal?.image = nil cell.imageFavorite.image = nil cell.imageShared.image = nil cell.imageMore.image = nil @@ -153,7 +153,7 @@ extension NCShareExtension: UICollectionViewDataSource { // Local image: offline if tableDirectory != nil && tableDirectory!.offline { - cell.imageLocal.image = NCImageCache.shared.getImageOfflineFlag() + cell.imageLocal?.image = NCImageCache.shared.getImageOfflineFlag() } } } diff --git a/iOSClient/Account/Account Request/NCShareAccounts.swift b/iOSClient/Account/Account Request/NCShareAccounts.swift index fd1a286695..c0c2142aea 100644 --- a/iOSClient/Account/Account Request/NCShareAccounts.swift +++ b/iOSClient/Account/Account Request/NCShareAccounts.swift @@ -65,7 +65,6 @@ extension NCShareAccounts: UITableViewDelegate { } extension NCShareAccounts: UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return accounts.count } diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index 14963076bd..cfd6af9ef4 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -2,12 +2,16 @@ // SPDX-FileCopyrightText: 2020 Marino Faggiana // SPDX-License-Identifier: GPL-3.0-or-later +import Foundation import UIKit +import NextcloudKit +import RealmSwift protocol NCCellProtocol { var metadata: tableMetadata? {get set } var avatarImage: UIImageView? { get } var previewImage: UIImageView? { get set } + var imageLocal: UIImageView? { get set } } extension NCCellProtocol { @@ -23,4 +27,127 @@ extension NCCellProtocol { get { return nil } set {} } + var imageLocal: UIImageView? { + get { return nil } + set {} + } +} + +#if !EXTENSION +extension NCCollectionViewCommon { + func setCellDirectory(cell: NCCellProtocol, metadata: tableMetadata, isShare: Bool, isMounted: Bool) { + let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) + + if metadata.e2eEncrypted { + cell.previewImage?.image = imageCache.getFolderEncrypted(account: metadata.account) + } else if isShare { + cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? + (cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { + cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account) + } else if metadata.mountType == "group" { + cell.previewImage?.image = imageCache.getFolderGroup(account: metadata.account) + } else if isMounted { + cell.previewImage?.image = imageCache.getFolderExternal(account: metadata.account) + } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { + cell.previewImage?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + } else { + cell.previewImage?.image = imageCache.getFolder(account: metadata.account) + } + + // Local image: offline + metadata.isOffline = tblDirectory?.offline ?? false + + if metadata.isOffline { + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } + + // color folder + cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + } + + func setCellFile(cell: NCCellProtocol, metadata: tableMetadata,) { + let ext = global.getSizeExtension(column: self.numberOfColumns) + let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) + + if metadata.hasPreviewBorder { + cell.previewImage?.layer.borderWidth = 0.2 + cell.previewImage?.layer.borderColor = UIColor.lightGray.cgColor + } + + if metadata.name == global.appName { + if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { + cell.previewImage?.image = image + } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { + cell.previewImage?.image = image + } + + if cell.previewImage?.image == nil { + if metadata.iconName.isEmpty { + cell.previewImage?.image = NCImageCache.shared.getImageFile() + } else { + cell.previewImage?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + } + } + } else { + // APP NAME - UNIFIED SEARCH + switch metadata.iconName { + case let str where str.contains("contacts"): + cell.previewImage?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("conversation"): + cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("calendar"): + cell.previewImage?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("deck"): + cell.previewImage?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("mail"): + cell.previewImage?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("talk"): + cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + case let str where str.contains("confirm"): + cell.previewImage?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + case let str where str.contains("pages"): + cell.previewImage?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + default: + cell.previewImage?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + } + if !metadata.iconUrl.isEmpty { + if let ownerId = getAvatarFromIconUrl(metadata: metadata) { + let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) + if let image = NCImageCache.shared.getImageCache(key: fileName) { + cell.previewImage?.image = image + } else { + self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in + if let image { + cell.previewImage?.image = image + NCImageCache.shared.addImageCache(image: image, key: fileName) + } else { + cell.previewImage?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + } + + if !(tblAvatar?.loaded ?? false), + self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { + self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImage: true)) + } + } + } + } + } + } + + // Local image: offline + metadata.isOffline = tableLocalFile?.offline ?? false + + if metadata.isOffline { + //a11yValues.append(NSLocalizedString("_offline_", comment: "")) + cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + } else if utilityFileSystem.fileProviderStorageExists(metadata) { + cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + } + } + } +#endif diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 829f5f38ea..15c0fe81be 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -33,9 +33,6 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } - var avatarImage: UIImageView? { - return nil - } var previewImage: UIImageView? { get { return imageItem } set { imageItem = newValue } @@ -194,7 +191,6 @@ extension NCCollectionViewCommon { var isShare = false var isMounted = false var a11yValues: [String] = [] - let ext = global.getSizeExtension(column: self.numberOfColumns) let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) // CONTENT MODE @@ -231,115 +227,9 @@ extension NCCollectionViewCommon { } if metadata.directory { - let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) - - if metadata.e2eEncrypted { - cell.previewImage?.image = imageCache.getFolderEncrypted(account: metadata.account) - } else if isShare { - cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account) - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) - } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account) - } else if metadata.mountType == "group" { - cell.previewImage?.image = imageCache.getFolderGroup(account: metadata.account) - } else if isMounted { - cell.previewImage?.image = imageCache.getFolderExternal(account: metadata.account) - } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImage?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) - } else { - cell.previewImage?.image = imageCache.getFolder(account: metadata.account) - } - - // Local image: offline - metadata.isOffline = tblDirectory?.offline ?? false - - if metadata.isOffline { - cell.imageLocal.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } - - // color folder - cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) - + setCellDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) } else { - let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - - if metadata.hasPreviewBorder { - cell.previewImage?.layer.borderWidth = 0.2 - cell.previewImage?.layer.borderColor = UIColor.lightGray.cgColor - } - - if metadata.name == global.appName { - if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImage?.image = image - } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImage?.image = image - } - - if cell.previewImage?.image == nil { - if metadata.iconName.isEmpty { - cell.previewImage?.image = NCImageCache.shared.getImageFile() - } else { - cell.previewImage?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) - } - } - } else { - // APP NAME - UNIFIED SEARCH - switch metadata.iconName { - case let str where str.contains("contacts"): - cell.previewImage?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("conversation"): - cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("calendar"): - cell.previewImage?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("deck"): - cell.previewImage?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("mail"): - cell.previewImage?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("talk"): - cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("confirm"): - cell.previewImage?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("pages"): - cell.previewImage?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) - default: - cell.previewImage?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) - } - if !metadata.iconUrl.isEmpty { - if let ownerId = getAvatarFromIconUrl(metadata: metadata) { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImage?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.previewImage?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.previewImage?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImage: true)) - } - } - } - } - } - } - - // Local image: offline - metadata.isOffline = tableLocalFile?.offline ?? false - - if metadata.isOffline { - a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) - } + setCellFile(cell: cell, metadata: metadata) } // image Favorite @@ -392,7 +282,7 @@ extension NCCollectionViewCommon { // URL if metadata.classFile == NKTypeClassFile.url.rawValue { - cell.imageLocal?.image = nil + cell.imageLocal.image = nil } // Edit mode diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index d488ffa392..65e9b17426 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -380,7 +380,6 @@ extension NCCollectionViewCommon { var isShare = false var isMounted = false var a11yValues: [String] = [] - let ext = global.getSizeExtension(column: self.numberOfColumns) let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) // CONTENT MODE @@ -425,115 +424,9 @@ extension NCCollectionViewCommon { } if metadata.directory { - let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) - - if metadata.e2eEncrypted { - cell.previewImage?.image = imageCache.getFolderEncrypted(account: metadata.account) - } else if isShare { - cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account) - } else if !metadata.shareType.isEmpty { - metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) - } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account) - } else if metadata.mountType == "group" { - cell.previewImage?.image = imageCache.getFolderGroup(account: metadata.account) - } else if isMounted { - cell.previewImage?.image = imageCache.getFolderExternal(account: metadata.account) - } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImage?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) - } else { - cell.previewImage?.image = imageCache.getFolder(account: metadata.account) - } - - // Local image: offline - metadata.isOffline = tblDirectory?.offline ?? false - - if metadata.isOffline { - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } - - // color folder - cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) - + setCellDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) } else { - let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) - - if metadata.hasPreviewBorder { - cell.previewImage?.layer.borderWidth = 0.2 - cell.previewImage?.layer.borderColor = UIColor.lightGray.cgColor - } - - if metadata.name == global.appName { - if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImage?.image = image - } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImage?.image = image - } - - if cell.previewImage?.image == nil { - if metadata.iconName.isEmpty { - cell.previewImage?.image = NCImageCache.shared.getImageFile() - } else { - cell.previewImage?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) - } - } - } else { - // APP NAME - UNIFIED SEARCH - switch metadata.iconName { - case let str where str.contains("contacts"): - cell.previewImage?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("conversation"): - cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("calendar"): - cell.previewImage?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("deck"): - cell.previewImage?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("mail"): - cell.previewImage?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("talk"): - cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) - case let str where str.contains("confirm"): - cell.previewImage?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) - case let str where str.contains("pages"): - cell.previewImage?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) - default: - cell.previewImage?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) - } - if !metadata.iconUrl.isEmpty { - if let ownerId = getAvatarFromIconUrl(metadata: metadata) { - let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) - if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImage?.image = image - } else { - self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in - if let image { - cell.previewImage?.image = image - NCImageCache.shared.addImageCache(image: image, key: fileName) - } else { - cell.previewImage?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) - } - - if !(tblAvatar?.loaded ?? false), - self.networking.downloadAvatarQueue.operations.filter({ ($0 as? NCOperationDownloadAvatar)?.fileName == fileName }).isEmpty { - self.networking.downloadAvatarQueue.addOperation(NCOperationDownloadAvatar(user: ownerId, fileName: fileName, account: metadata.account, view: self.collectionView, isPreviewImage: true)) - } - } - } - } - } - } - - // Local image: offline - metadata.isOffline = tableLocalFile?.offline ?? false - - if metadata.isOffline { - a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) - } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) - } + setCellFile(cell: cell, metadata: metadata) } // image Favorite @@ -622,7 +515,7 @@ extension NCCollectionViewCommon { // URL if metadata.classFile == NKTypeClassFile.url.rawValue { - cell.imageLocal?.image = nil + cell.imageLocal.image = nil cell.hideButtonShare(true) cell.hideButtonMore(true) } diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index ecaa6c6207..5432a26310 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -11,9 +11,6 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProt // Cell Protocol var metadata: tableMetadata? - var avatarImage: UIImageView? { - return nil - } var previewImage: UIImageView? { get { return imageItem } set { imageItem = newValue } @@ -61,7 +58,6 @@ extension NCCollectionViewCommon { // MARK: - LAYOUT PHOTO // func photoCell(cell: NCPhotoCell, indexPath: IndexPath, metadata: tableMetadata) -> NCPhotoCell { - let width = UIScreen.main.bounds.width / CGFloat(self.numberOfColumns) let ext = global.getSizeExtension(column: self.numberOfColumns) cell.metadata = metadata diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 61e2761ca1..09b0f3bbb2 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -384,7 +384,7 @@ extension NCSelect: UICollectionViewDataSource { cell.imageSelect.image = nil cell.imageStatus.image = nil - cell.imageLocal.image = nil + cell.imageLocal?.image = nil cell.imageFavorite.image = nil cell.imageShared.image = nil cell.imageMore.image = nil @@ -419,9 +419,9 @@ extension NCSelect: UICollectionViewDataSource { self.database.getTableLocal(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) { tblLocalFile in if let tblLocalFile, tblLocalFile.offline { - cell.imageLocal.image = NCImageCache.shared.getImageOfflineFlag() + cell.imageLocal?.image = NCImageCache.shared.getImageOfflineFlag() } else if self.utilityFileSystem.fileProviderStorageExists(metadata) { - cell.imageLocal.image = NCImageCache.shared.getImageLocal() + cell.imageLocal?.image = NCImageCache.shared.getImageLocal() } } } From a6b6f7d3c48c9af764362eab99b4725ec4828587 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sat, 14 Feb 2026 12:08:34 +0100 Subject: [PATCH 11/22] cleaning Signed-off-by: Marino Faggiana --- iOSClient/Activity/NCActivity.swift | 8 +++--- .../Activity/NCActivityTableViewCell.swift | 26 ++++--------------- iOSClient/Notification/NCNotification.swift | 24 +++++------------ iOSClient/Share/NCShare.swift | 2 +- iOSClient/Share/NCShareCommentsCell.swift | 2 +- iOSClient/Share/NCShareUserCell.swift | 8 +++--- 6 files changed, 22 insertions(+), 48 deletions(-) diff --git a/iOSClient/Activity/NCActivity.swift b/iOSClient/Activity/NCActivity.swift index ac0cb3fc0d..2dc793228a 100644 --- a/iOSClient/Activity/NCActivity.swift +++ b/iOSClient/Activity/NCActivity.swift @@ -264,7 +264,7 @@ extension NCActivity: UITableViewDataSource { cell.idActivity = activity.idActivity cell.account = activity.account - cell.indexPath = indexPath + cell.index = indexPath cell.avatar.image = nil cell.avatar.isHidden = true cell.didSelectItemEnable = self.didSelectItemEnable @@ -288,7 +288,7 @@ extension NCActivity: UITableViewDataSource { // avatar if !activity.user.isEmpty && activity.user != session.userId { cell.avatar.isHidden = false - cell.fileUser = activity.user + cell.user = activity.user cell.subjectLeadingConstraint.constant = 15 cell.configureAvatarMenu() @@ -296,9 +296,9 @@ extension NCActivity: UITableViewDataSource { let results = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) if results.image == nil { - cell.avatarImage?.image = utility.loadUserImage(for: activity.user, displayName: nil, urlBase: session.urlBase) + cell.avatar?.image = utility.loadUserImage(for: activity.user, displayName: nil, urlBase: session.urlBase) } else { - cell.avatarImage?.image = results.image + cell.avatar?.image = results.image } if !(results.tblAvatar?.loaded ?? false), diff --git a/iOSClient/Activity/NCActivityTableViewCell.swift b/iOSClient/Activity/NCActivityTableViewCell.swift index 88126d3e91..35bd4932f0 100644 --- a/iOSClient/Activity/NCActivityTableViewCell.swift +++ b/iOSClient/Activity/NCActivityTableViewCell.swift @@ -14,15 +14,15 @@ class NCActivityCollectionViewCell: UICollectionViewCell { var indexPath = IndexPath() } -class NCActivityTableViewCell: UITableViewCell, NCCellProtocol { +class NCActivityTableViewCell: UITableViewCell { @IBOutlet weak var icon: UIImageView! @IBOutlet weak var avatar: UIImageView! @IBOutlet weak var subject: UILabel! @IBOutlet weak var subjectLeadingConstraint: NSLayoutConstraint! - private var user: String = "" - private var index = IndexPath() - private var avatarButton: UIButton! + var user: String = "" + var index = IndexPath() + var avatarButton: UIButton! var idActivity: Int = 0 var activityPreviews: [tableActivityPreview] = [] @@ -32,18 +32,6 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol { var account: String! let utility = NCUtility() - var indexPath: IndexPath { - get { return index } - set { index = newValue } - } - var avatarImage: UIImageView? { - return avatar - } - var fileUser: String? { - get { return user } - set { user = newValue ?? "" } - } - override func awakeFromNib() { super.awakeFromNib() @@ -61,13 +49,9 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol { } func configureAvatarMenu() { - guard let fileUser = fileUser else { - avatarButton.menu = nil - return - } let session = NCSession.shared.getSession(account: account) - avatarButton.menu = NCContextMenuProfile(userId: fileUser, session: session, viewController: viewController).viewMenu() + avatarButton.menu = NCContextMenuProfile(userId: user, session: session, viewController: viewController).viewMenu() } } diff --git a/iOSClient/Notification/NCNotification.swift b/iOSClient/Notification/NCNotification.swift index 9d670088ab..1f6f70084e 100644 --- a/iOSClient/Notification/NCNotification.swift +++ b/iOSClient/Notification/NCNotification.swift @@ -114,7 +114,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate { guard let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? NCNotificationCell else { return UITableViewCell() } cell.delegate = self cell.selectionStyle = .none - cell.indexPath = indexPath + cell.index = indexPath let notification = notifications[indexPath.row] let urlIcon = URL(string: notification.icon) @@ -142,9 +142,9 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate { let results = NCManageDatabase.shared.getImageAvatarLoaded(fileName: fileName) if results.image == nil { - cell.avatarImage?.image = utility.loadUserImage(for: user, displayName: json["user"]?["name"].string, urlBase: session.urlBase) + cell.avatar?.image = utility.loadUserImage(for: user, displayName: json["user"]?["name"].string, urlBase: session.urlBase) } else { - cell.avatarImage?.image = results.image + cell.avatar?.image = results.image } if !(results.tblAvatar?.loaded ?? false), @@ -353,7 +353,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate { // MARK: - -class NCNotificationCell: UITableViewCell, NCCellProtocol { +class NCNotificationCell: UITableViewCell { @IBOutlet weak var icon: UIImageView! @IBOutlet weak var avatar: UIImageView! @@ -368,24 +368,12 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol { @IBOutlet weak var primaryWidth: NSLayoutConstraint! @IBOutlet weak var secondaryWidth: NSLayoutConstraint! - private var user = "" - private var index = IndexPath() + var user = "" + var index = IndexPath() weak var delegate: NCNotificationCellDelegate? var notification: NKNotifications? - var indexPath: IndexPath { - get { return index } - set { index = newValue } - } - var avatarImage: UIImageView? { - return avatar - } - var fileUser: String? { - get { return user } - set { user = newValue ?? "" } - } - @IBAction func touchUpInsideRemove(_ sender: Any) { guard let notification = notification else { return } delegate?.tapRemove(with: notification, sender: sender) diff --git a/iOSClient/Share/NCShare.swift b/iOSClient/Share/NCShare.swift index 02b4ee6fe4..fbe1b89155 100644 --- a/iOSClient/Share/NCShare.swift +++ b/iOSClient/Share/NCShare.swift @@ -484,7 +484,7 @@ extension NCShare: UITableViewDataSource { } else { // USER / GROUP etc. if let cell = tableView.dequeueReusableCell(withIdentifier: "cellUser", for: indexPath) as? NCShareUserCell { - cell.indexPath = indexPath + cell.index = indexPath cell.tableShare = tableShare cell.isDirectory = metadata.directory cell.delegate = self diff --git a/iOSClient/Share/NCShareCommentsCell.swift b/iOSClient/Share/NCShareCommentsCell.swift index 7da775c97b..9bbf034968 100644 --- a/iOSClient/Share/NCShareCommentsCell.swift +++ b/iOSClient/Share/NCShareCommentsCell.swift @@ -26,7 +26,7 @@ import NextcloudKit // MARK: - NCShareCommentsCell -class NCShareCommentsCell: UITableViewCell, NCCellProtocol { +class NCShareCommentsCell: UITableViewCell { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var labelUser: UILabel! diff --git a/iOSClient/Share/NCShareUserCell.swift b/iOSClient/Share/NCShareUserCell.swift index cbaf259d12..442b50c17b 100644 --- a/iOSClient/Share/NCShareUserCell.swift +++ b/iOSClient/Share/NCShareUserCell.swift @@ -24,7 +24,7 @@ import UIKit import DropDown import NextcloudKit -class NCShareUserCell: UITableViewCell, NCCellProtocol { +class NCShareUserCell: UITableViewCell { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var labelTitle: UILabel! @IBOutlet weak var buttonMenu: UIButton! @@ -34,14 +34,15 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol { @IBOutlet weak var labelQuickStatus: UILabel! @IBOutlet weak var imageDownArrow: UIImageView! - private var index = IndexPath() - private var avatarButton: UIButton! + var index = IndexPath() + var avatarButton: UIButton! var tableShare: tableShare? var isDirectory = false let utility = NCUtility() weak var delegate: NCShareUserCellDelegate? + /* var indexPath: IndexPath { get { return index } set { index = newValue } @@ -53,6 +54,7 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol { get { return tableShare?.shareWith } set {} } + */ func setupCellUI(userId: String, session: NCSession.Session, metadata: tableMetadata) { guard let tableShare = tableShare else { From ee884e2133409784e8dbc13d34704da8658d6697 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sat, 14 Feb 2026 12:14:32 +0100 Subject: [PATCH 12/22] cod Signed-off-by: Marino Faggiana --- iOSClient/Select/NCSelect.swift | 6 ++--- iOSClient/Share/NCShareUserCell.swift | 32 +++------------------------ 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 09b0f3bbb2..83ec7863bf 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -337,12 +337,12 @@ extension NCSelect: UICollectionViewDataSource { // Thumbnail if !metadata.directory { if let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: NCGlobal.shared.previewExt512, userId: metadata.userId, urlBase: metadata.urlBase) { - (cell as? NCCellProtocol)?.previewImage?.image = image + (cell as? NCListCell)?.previewImage?.image = image } else { if metadata.iconName.isEmpty { - (cell as? NCCellProtocol)?.previewImage?.image = NCImageCache.shared.getImageFile() + (cell as? NCListCell)?.previewImage?.image = NCImageCache.shared.getImageFile() } else { - (cell as? NCCellProtocol)?.previewImage?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + (cell as? NCListCell)?.previewImage?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } if metadata.hasPreview, metadata.status == NCGlobal.shared.metadataStatusNormal { diff --git a/iOSClient/Share/NCShareUserCell.swift b/iOSClient/Share/NCShareUserCell.swift index 442b50c17b..87e692ce31 100644 --- a/iOSClient/Share/NCShareUserCell.swift +++ b/iOSClient/Share/NCShareUserCell.swift @@ -42,20 +42,6 @@ class NCShareUserCell: UITableViewCell { let utility = NCUtility() weak var delegate: NCShareUserCellDelegate? - /* - var indexPath: IndexPath { - get { return index } - set { index = newValue } - } - var avatarImage: UIImageView? { - return imageItem - } - var fileUser: String? { - get { return tableShare?.shareWith } - set {} - } - */ - func setupCellUI(userId: String, session: NCSession.Session, metadata: tableMetadata) { guard let tableShare = tableShare else { return @@ -173,7 +159,7 @@ protocol NCShareUserCellDelegate: AnyObject { // MARK: - NCSearchUserDropDownCell -class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol { +class NCSearchUserDropDownCell: DropDownCell { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var imageStatus: UIImageView! @@ -181,22 +167,10 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol { @IBOutlet weak var imageShareeType: UIImageView! @IBOutlet weak var centerTitle: NSLayoutConstraint! - private var user: String = "" - private var index = IndexPath() + var user: String = "" + var index = IndexPath() private let utilityFileSystem = NCUtilityFileSystem() - var indexPath: IndexPath { - get { return index } - set { index = newValue } - } - var avatarImage: UIImageView? { - return imageItem - } - var fileUser: String? { - get { return user } - set { user = newValue ?? "" } - } - func setupCell(sharee: NKSharee, session: NCSession.Session) { let utility = NCUtility() imageItem.image = NCShareCommon.getImageShareType(shareType: sharee.shareType) From 2b68a755d18fbd60b10d53368e927da3de997496 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sat, 14 Feb 2026 16:42:06 +0100 Subject: [PATCH 13/22] fix Signed-off-by: Marino Faggiana --- .../Cell/NCCellProtocol.swift | 4 ++-- .../Collection Common/Cell/NCGridCell.swift | 2 +- .../Collection Common/Cell/NCListCell.swift | 2 +- .../NCCollectionViewCommon.swift | 24 ------------------- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index cfd6af9ef4..171d4cb1a9 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -69,7 +69,7 @@ extension NCCollectionViewCommon { cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) } - func setCellFile(cell: NCCellProtocol, metadata: tableMetadata,) { + func setCellFile(cell: NCCellProtocol, metadata: tableMetadata, a11yValues: inout [String]) { let ext = global.getSizeExtension(column: self.numberOfColumns) let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) @@ -142,7 +142,7 @@ extension NCCollectionViewCommon { metadata.isOffline = tableLocalFile?.offline ?? false if metadata.isOffline { - //a11yValues.append(NSLocalizedString("_offline_", comment: "")) + a11yValues.append(NSLocalizedString("_offline_", comment: "")) cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) } else if utilityFileSystem.fileProviderStorageExists(metadata) { cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 15c0fe81be..9974ef9b43 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -229,7 +229,7 @@ extension NCCollectionViewCommon { if metadata.directory { setCellDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) } else { - setCellFile(cell: cell, metadata: metadata) + setCellFile(cell: cell, metadata: metadata, a11yValues: &a11yValues) } // image Favorite diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 65e9b17426..ca891d7d6f 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -426,7 +426,7 @@ extension NCCollectionViewCommon { if metadata.directory { setCellDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) } else { - setCellFile(cell: cell, metadata: metadata) + setCellFile(cell: cell, metadata: metadata, a11yValues: &a11yValues) } // image Favorite diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 543362aea8..909a54d013 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -185,8 +185,6 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate, searchBar?.autocapitalizationType = .none searchBar?.backgroundImage = UIImage() - updateSearchFieldAppearance() - navigationItem.searchController = searchController navigationItem.hidesSearchBarWhenScrolling = false } @@ -358,7 +356,6 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate, super.viewWillTransition(to: size, with: coordinator) coordinator.animate(alongsideTransition: { _ in - self.updateSearchFieldAppearance() self.collectionView?.collectionViewLayout.invalidateLayout() }) @@ -369,27 +366,6 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate, return true } - private func updateSearchFieldAppearance() { - let textField = searchController?.searchBar.searchTextField - - if traitCollection.horizontalSizeClass == .regular { - textField?.backgroundColor = nil - textField?.layer.cornerRadius = 0 - textField?.layer.shadowOpacity = 0 - } else { - textField?.backgroundColor = UIColor { trait in - trait.userInterfaceStyle == .dark ? UIColor.systemGray.withAlphaComponent(0.20) : .white - } - textField?.borderStyle = .none - textField?.layer.cornerRadius = 21 - textField?.layer.masksToBounds = false - textField?.layer.shadowColor = UIColor.black.withAlphaComponent(0.10).cgColor - textField?.layer.shadowOpacity = 1 - textField?.layer.shadowOffset = .zero - textField?.layer.shadowRadius = 1.1 - } - } - func presentationControllerDidDismiss( _ presentationController: UIPresentationController) { let viewController = presentationController.presentedViewController From 749cdfb2f919864638771e60510a7e1b8489e3a8 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sat, 14 Feb 2026 16:45:38 +0100 Subject: [PATCH 14/22] code Signed-off-by: Marino Faggiana --- .../Collection Common/Cell/NCCellProtocol.swift | 13 +++++++++---- .../Main/Collection Common/Cell/NCGridCell.swift | 2 +- .../Main/Collection Common/Cell/NCListCell.swift | 2 +- .../Main/Collection Common/Cell/NCPhotoCell.swift | 2 +- .../NCCollectionViewDownloadThumbnail.swift | 2 +- iOSClient/Networking/NCNetworking+WebDAV.swift | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift index 171d4cb1a9..1a64b39de3 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift @@ -7,14 +7,14 @@ import UIKit import NextcloudKit import RealmSwift -protocol NCCellProtocol { +protocol NCCellMainProtocol { var metadata: tableMetadata? {get set } var avatarImage: UIImageView? { get } var previewImage: UIImageView? { get set } var imageLocal: UIImageView? { get set } } -extension NCCellProtocol { +extension NCCellMainProtocol { var metadata: tableMetadata? { get { return nil } set {} @@ -35,7 +35,10 @@ extension NCCellProtocol { #if !EXTENSION extension NCCollectionViewCommon { - func setCellDirectory(cell: NCCellProtocol, metadata: tableMetadata, isShare: Bool, isMounted: Bool) { + func setCellDirectory(cell: NCCellMainProtocol, + metadata: tableMetadata, + isShare: Bool, + isMounted: Bool) { let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) if metadata.e2eEncrypted { @@ -69,7 +72,9 @@ extension NCCollectionViewCommon { cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) } - func setCellFile(cell: NCCellProtocol, metadata: tableMetadata, a11yValues: inout [String]) { + func setCellFile(cell: NCCellMainProtocol, + metadata: tableMetadata, + a11yValues: inout [String]) { let ext = global.getSizeExtension(column: self.numberOfColumns) let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 9974ef9b43..63af342932 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -12,7 +12,7 @@ protocol NCGridCellDelegate: AnyObject { func openContextMenu(with metadata: tableMetadata?, button: UIButton, sender: Any) } -class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProtocol { +class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainProtocol { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var imageSelect: UIImageView! @IBOutlet weak var imageStatus: UIImageView! diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index ca891d7d6f..545698f9a9 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -13,7 +13,7 @@ protocol NCListCellDelegate: AnyObject { func tapShareListItem(with metadata: tableMetadata?, button: UIButton, sender: Any) } -class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProtocol { +class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainProtocol { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var imageSelect: UIImageView! @IBOutlet weak var imageStatus: UIImageView! diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index 5432a26310..bc9317243b 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -4,7 +4,7 @@ import UIKit -class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProtocol { +class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainProtocol { @IBOutlet weak var imageItem: UIImageView! @IBOutlet weak var imageSelect: UIImageView! @IBOutlet weak var imageVisualEffect: UIVisualEffectView! diff --git a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift index 3dccfa45d5..ccc36af656 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift @@ -42,7 +42,7 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation, @unchecked Sendabl let image = self.utility.getImage(ocId: self.metadata.ocId, etag: self.metadata.etag, ext: self.ext, userId: self.metadata.userId, urlBase: self.metadata.urlBase) Task { @MainActor in - for case let cell as NCCellProtocol in collectionView.visibleCells where cell.metadata?.ocId == self.metadata.ocId { + for case let cell as NCCellMainProtocol in collectionView.visibleCells where cell.metadata?.ocId == self.metadata.ocId { if let previewImage = cell.previewImage { previewImage.contentMode = .scaleAspectFill diff --git a/iOSClient/Networking/NCNetworking+WebDAV.swift b/iOSClient/Networking/NCNetworking+WebDAV.swift index 0490ae6c11..08ae57c4de 100644 --- a/iOSClient/Networking/NCNetworking+WebDAV.swift +++ b/iOSClient/Networking/NCNetworking+WebDAV.swift @@ -880,7 +880,7 @@ class NCOperationDownloadAvatar: ConcurrentOperation, @unchecked Sendable { DispatchQueue.main.async { let visibleCells: [UIView] = (self.view as? UICollectionView)?.visibleCells ?? (self.view as? UITableView)?.visibleCells ?? [] - for case let cell as NCCellProtocol in visibleCells { + for case let cell as NCCellMainProtocol in visibleCells { if self.user == cell.metadata?.ownerId { if self.isPreviewImage, let previewImage = cell.previewImage { UIView.transition(with: previewImage, duration: 0.75, options: .transitionCrossDissolve, animations: { previewImage.image = image}, completion: nil) From 2176ebac128c158336391069f579d116a294eb1a Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sat, 14 Feb 2026 17:07:48 +0100 Subject: [PATCH 15/22] code Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 12 +++--- ...{NCCellProtocol.swift => NCCellMain.swift} | 14 +++---- .../Collection Common/Cell/NCGridCell.swift | 42 +++++++++---------- .../Collection Common/Cell/NCListCell.swift | 4 +- 4 files changed, 36 insertions(+), 36 deletions(-) rename iOSClient/Main/Collection Common/Cell/{NCCellProtocol.swift => NCCellMain.swift} (95%) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index e596212b38..59aa46a9a6 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -12,7 +12,7 @@ 2C33C48223E2C475005F963B /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C33C48123E2C475005F963B /* NotificationService.swift */; }; 2C33C48623E2C475005F963B /* Notification Service Extension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2C33C47F23E2C475005F963B /* Notification Service Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 2F96A1BAFB10ACFEAC68EF1C /* NCContextMenuPlayerTracks.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4C7A5B36D1ED178FB6B76CB /* NCContextMenuPlayerTracks.swift */; }; - 370D26AF248A3D7A00121797 /* NCCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 370D26AE248A3D7A00121797 /* NCCellProtocol.swift */; }; + 370D26AF248A3D7A00121797 /* NCCellMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 370D26AE248A3D7A00121797 /* NCCellMain.swift */; }; A5A87F9E4B0E4441A6A4BC20 /* NCContextMenuProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB7697C94BA14450A0867940 /* NCContextMenuProfile.swift */; }; AA3C85E82D36B08C00F74F12 /* UITestBackend.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA3C85E72D36B08C00F74F12 /* UITestBackend.swift */; }; AA3C85EB2D36BBFB00F74F12 /* OCSResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA3C85EA2D36BBF400F74F12 /* OCSResponse.swift */; }; @@ -871,7 +871,7 @@ F7EB9B132BBC12F300EDF036 /* UIApplication+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7EB9B122BBC12F300EDF036 /* UIApplication+Extension.swift */; }; F7ED547C25EEA65400956C55 /* QRCodeReader in Frameworks */ = {isa = PBXBuildFile; productRef = F7ED547B25EEA65400956C55 /* QRCodeReader */; }; F7EDE4D6262D7B9600414FE6 /* NCListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78ACD4121903CE00088454D /* NCListCell.swift */; }; - F7EDE4DB262D7BA200414FE6 /* NCCellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 370D26AE248A3D7A00121797 /* NCCellProtocol.swift */; }; + F7EDE4DB262D7BA200414FE6 /* NCCellMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 370D26AE248A3D7A00121797 /* NCCellMain.swift */; }; F7EDE509262DA9D600414FE6 /* NCSelectCommandViewSelect.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7EDE508262DA9D600414FE6 /* NCSelectCommandViewSelect.xib */; }; F7EDE514262DC2CD00414FE6 /* NCSelectCommandViewSelect+CreateFolder.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7EDE513262DC2CD00414FE6 /* NCSelectCommandViewSelect+CreateFolder.xib */; }; F7EDE51B262DD0C400414FE6 /* NCSelectCommandViewCopyMove.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7EDE51A262DD0C400414FE6 /* NCSelectCommandViewCopyMove.xib */; }; @@ -1106,7 +1106,7 @@ 2C33C47F23E2C475005F963B /* Notification Service Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Notification Service Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; 2C33C48123E2C475005F963B /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = ""; }; 2C33C48A23E2CC26005F963B /* Notification_Service_Extension-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Notification_Service_Extension-Bridging-Header.h"; sourceTree = ""; }; - 370D26AE248A3D7A00121797 /* NCCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCCellProtocol.swift; sourceTree = ""; }; + 370D26AE248A3D7A00121797 /* NCCellMain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCCellMain.swift; sourceTree = ""; }; 8932E90EC4278026D86CCCC9 /* NCContextMenuComment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCContextMenuComment.swift; sourceTree = ""; }; AA3C85E72D36B08C00F74F12 /* UITestBackend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITestBackend.swift; sourceTree = ""; }; AA3C85EA2D36BBF400F74F12 /* OCSResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OCSResponse.swift; sourceTree = ""; }; @@ -2457,7 +2457,7 @@ F75FE06B2BB01D0D00A0EFEF /* Cell */ = { isa = PBXGroup; children = ( - 370D26AE248A3D7A00121797 /* NCCellProtocol.swift */, + 370D26AE248A3D7A00121797 /* NCCellMain.swift */, F78ACD3F21903CC20088454D /* NCGridCell.swift */, F751247A2C42919C00E63DB8 /* NCPhotoCell.swift */, F78ACD4121903CE00088454D /* NCListCell.swift */, @@ -4244,7 +4244,7 @@ F799DF862C4B7E56003410B5 /* NCSectionHeader.swift in Sources */, F702F2D025EE5B5C008F8E80 /* NCGlobal.swift in Sources */, F72437802C10B92400C7C68D /* NCSharePermissions.swift in Sources */, - F7EDE4DB262D7BA200414FE6 /* NCCellProtocol.swift in Sources */, + F7EDE4DB262D7BA200414FE6 /* NCCellMain.swift in Sources */, F72944F62A8424F800246839 /* NCEndToEndMetadataV1.swift in Sources */, F73EF7BA2B0224AB0087E6E9 /* NCManageDatabase+ExternalSites.swift in Sources */, F711A4EB2AF9327D00095DD8 /* UIImage+animatedGIF.m in Sources */, @@ -4414,7 +4414,7 @@ F702F30825EE5D47008F8E80 /* NCPopupViewController.swift in Sources */, F76340FC2EBDF64D0056F538 /* NCManageDatabase+Tag.swift in Sources */, F733598125C1C188002ABA72 /* NCAskAuthorization.swift in Sources */, - 370D26AF248A3D7A00121797 /* NCCellProtocol.swift in Sources */, + 370D26AF248A3D7A00121797 /* NCCellMain.swift in Sources */, F32FADA92D1176E3007035E2 /* UIButton+Extension.swift in Sources */, F7DF7B3F2F1A2EF900514020 /* BannerView.swift in Sources */, F768822C2C0DD1E7001CF441 /* NCPreferences.swift in Sources */, diff --git a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift similarity index 95% rename from iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift rename to iOSClient/Main/Collection Common/Cell/NCCellMain.swift index 1a64b39de3..d859af8510 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellProtocol.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift @@ -35,10 +35,10 @@ extension NCCellMainProtocol { #if !EXTENSION extension NCCollectionViewCommon { - func setCellDirectory(cell: NCCellMainProtocol, - metadata: tableMetadata, - isShare: Bool, - isMounted: Bool) { + func cellMainDirectory(cell: NCCellMainProtocol, + metadata: tableMetadata, + isShare: Bool, + isMounted: Bool) { let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) if metadata.e2eEncrypted { @@ -72,9 +72,9 @@ extension NCCollectionViewCommon { cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) } - func setCellFile(cell: NCCellMainProtocol, - metadata: tableMetadata, - a11yValues: inout [String]) { + func cellMainFile(cell: NCCellMainProtocol, + metadata: tableMetadata, + a11yValues: inout [String]) { let ext = global.getSizeExtension(column: self.numberOfColumns) let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 63af342932..9f3d9ba4d3 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -227,14 +227,14 @@ extension NCCollectionViewCommon { } if metadata.directory { - setCellDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) + cellMainDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) } else { - setCellFile(cell: cell, metadata: metadata, a11yValues: &a11yValues) + cellMainFile(cell: cell, metadata: metadata, a11yValues: &a11yValues) } // image Favorite if metadata.favorite { - cell.imageFavorite?.image = imageCache.getImageFavorite() + cell.imageFavorite.image = imageCache.getImageFavorite() a11yValues.append(NSLocalizedString("_favorite_short_", comment: "")) } @@ -248,34 +248,34 @@ extension NCCollectionViewCommon { // Status if metadata.isLivePhoto { - cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + cell.imageStatus.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) } else if metadata.isVideo { - cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + cell.imageStatus.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) } switch metadata.status { case global.metadataStatusWaitCreateFolder: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + cell.imageStatus.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo.text = NSLocalizedString("_status_wait_create_folder_", comment: "") case global.metadataStatusWaitFavorite: - cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + cell.imageStatus.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo.text = NSLocalizedString("_status_wait_favorite_", comment: "") case global.metadataStatusWaitCopy: - cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") + cell.imageStatus.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo.text = NSLocalizedString("_status_wait_copy_", comment: "") case global.metadataStatusWaitMove: - cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") + cell.imageStatus.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo.text = NSLocalizedString("_status_wait_move_", comment: "") case global.metadataStatusWaitRename: - cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") + cell.imageStatus.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo.text = NSLocalizedString("_status_wait_rename_", comment: "") case global.metadataStatusWaitDownload: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloading: - cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.imageStatus.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) default: break } @@ -294,11 +294,11 @@ extension NCCollectionViewCommon { } // Accessibility - cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo?.text ?? "") + (cell.labelSubinfo?.text ?? ""), value: a11yValues.joined(separator: ", ")) + cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.labelInfo.text ?? "") + (cell.labelSubinfo.text ?? ""), value: a11yValues.joined(separator: ", ")) // Color string find in search - cell.labelTitle?.textColor = NCBrandColor.shared.textColor - cell.labelTitle?.font = .systemFont(ofSize: 15) + cell.labelTitle.textColor = NCBrandColor.shared.textColor + cell.labelTitle.font = .systemFont(ofSize: 15) // Obligatory here, at the end !! cell.metadata = metadata diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index 545698f9a9..af0fe9d768 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -424,9 +424,9 @@ extension NCCollectionViewCommon { } if metadata.directory { - setCellDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) + cellMainDirectory(cell: cell, metadata: metadata, isShare: isShare, isMounted: isMounted) } else { - setCellFile(cell: cell, metadata: metadata, a11yValues: &a11yValues) + cellMainFile(cell: cell, metadata: metadata, a11yValues: &a11yValues) } // image Favorite From 97c25ab6a63c79c394586dab08a462cd23399b10 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sat, 14 Feb 2026 17:10:01 +0100 Subject: [PATCH 16/22] code Signed-off-by: Marino Faggiana --- iOSClient/Main/Collection Common/Cell/NCCellMain.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift index d859af8510..6292be03d5 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift @@ -75,7 +75,6 @@ extension NCCollectionViewCommon { func cellMainFile(cell: NCCellMainProtocol, metadata: tableMetadata, a11yValues: inout [String]) { - let ext = global.getSizeExtension(column: self.numberOfColumns) let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) if metadata.hasPreviewBorder { @@ -84,6 +83,7 @@ extension NCCollectionViewCommon { } if metadata.name == global.appName { + let ext = global.getSizeExtension(column: self.numberOfColumns) if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { cell.previewImage?.image = image } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { From 59e1171419b6d22d39fb509f48f203603ff6c820 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sat, 14 Feb 2026 18:14:08 +0100 Subject: [PATCH 17/22] code Signed-off-by: Marino Faggiana --- .../Collection Common/Cell/NCCellMain.swift | 37 ++++++++++++++++++ .../Collection Common/Cell/NCGridCell.swift | 33 +--------------- .../Collection Common/Cell/NCListCell.swift | 39 ++----------------- 3 files changed, 42 insertions(+), 67 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift index 6292be03d5..c92e087d1a 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift @@ -35,6 +35,43 @@ extension NCCellMainProtocol { #if !EXTENSION extension NCCollectionViewCommon { + func cellMainStatus(cell: NCCellMainProtocol, + metadata: tableMetadata, + a11yValues: inout [String]) { + if metadata.isLivePhoto { + cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) + } else if metadata.isVideo { + cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + } + + switch metadata.status { + case global.metadataStatusWaitCreateFolder: + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + case global.metadataStatusWaitFavorite: + cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + case global.metadataStatusWaitCopy: + cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") + case global.metadataStatusWaitMove: + cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") + case global.metadataStatusWaitRename: + cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") + case global.metadataStatusWaitDownload: + cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloading: + cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + case global.metadataStatusDownloadError, global.metadataStatusUploadError: + cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + default: + break + } + + } func cellMainDirectory(cell: NCCellMainProtocol, metadata: tableMetadata, isShare: Bool, diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 9f3d9ba4d3..7e78634846 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -247,38 +247,7 @@ extension NCCollectionViewCommon { } // Status - if metadata.isLivePhoto { - cell.imageStatus.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) - a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) - } else if metadata.isVideo { - cell.imageStatus.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) - } - - switch metadata.status { - case global.metadataStatusWaitCreateFolder: - cell.imageStatus.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo.text = NSLocalizedString("_status_wait_create_folder_", comment: "") - case global.metadataStatusWaitFavorite: - cell.imageStatus.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo.text = NSLocalizedString("_status_wait_favorite_", comment: "") - case global.metadataStatusWaitCopy: - cell.imageStatus.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo.text = NSLocalizedString("_status_wait_copy_", comment: "") - case global.metadataStatusWaitMove: - cell.imageStatus.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo.text = NSLocalizedString("_status_wait_move_", comment: "") - case global.metadataStatusWaitRename: - cell.imageStatus.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo.text = NSLocalizedString("_status_wait_rename_", comment: "") - case global.metadataStatusWaitDownload: - cell.imageStatus.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloading: - cell.imageStatus.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.imageStatus.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) - default: - break - } + cellMainStatus(cell: cell, metadata: metadata, a11yValues: &a11yValues) // URL if metadata.classFile == NKTypeClassFile.url.rawValue { diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index af0fe9d768..d295348d9c 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -396,9 +396,9 @@ extension NCCollectionViewCommon { return cell } - if metadataFolder != nil { - isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionShared) - isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder!.permissions.contains(NCMetadataPermissions.permissionMounted) + if let metadataFolder { + isShare = metadata.permissions.contains(NCMetadataPermissions.permissionShared) && !metadataFolder.permissions.contains(NCMetadataPermissions.permissionShared) + isMounted = metadata.permissions.contains(NCMetadataPermissions.permissionMounted) && !metadataFolder.permissions.contains(NCMetadataPermissions.permissionMounted) } if isSearchingMode { @@ -455,38 +455,7 @@ extension NCCollectionViewCommon { } // Status - if metadata.isLivePhoto { - cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) - a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) - } else if metadata.isVideo { - cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) - } - - switch metadata.status { - case global.metadataStatusWaitCreateFolder: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") - case global.metadataStatusWaitFavorite: - cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") - case global.metadataStatusWaitCopy: - cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") - case global.metadataStatusWaitMove: - cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") - case global.metadataStatusWaitRename: - cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") - case global.metadataStatusWaitDownload: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloading: - cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) - case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) - default: - break - } + cellMainStatus(cell: cell, metadata: metadata, a11yValues: &a11yValues) // AVATAR if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { From 70631896d8a8cb1e443d1a34c59afad95f69ac08 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sun, 15 Feb 2026 09:42:42 +0100 Subject: [PATCH 18/22] cleaning code Signed-off-by: Marino Faggiana --- .../Collection Common/Cell/NCCellMain.swift | 13 +++++++- .../Collection Common/Cell/NCGridCell.swift | 6 ++++ .../Collection Common/Cell/NCListCell.swift | 31 ++++++++++++------- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift index c92e087d1a..2735f872c5 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift @@ -12,6 +12,9 @@ protocol NCCellMainProtocol { var avatarImage: UIImageView? { get } var previewImage: UIImageView? { get set } var imageLocal: UIImageView? { get set } + var imageStatus: UIImageView? { get set } + var labelInfo: UILabel? { get set } + } extension NCCellMainProtocol { @@ -31,6 +34,14 @@ extension NCCellMainProtocol { get { return nil } set {} } + var imageStatus: UIImageView? { + get { return nil } + set {} + } + var labelInfo: UILabel? { + get { return nil } + set {} + } } #if !EXTENSION @@ -44,7 +55,7 @@ extension NCCollectionViewCommon { } else if metadata.isVideo { cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) } - + switch metadata.status { case global.metadataStatusWaitCreateFolder: cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 7e78634846..5a5d99bf09 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -18,10 +18,13 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP @IBOutlet weak var imageStatus: UIImageView! @IBOutlet weak var imageFavorite: UIImageView! @IBOutlet weak var imageLocal: UIImageView! + @IBOutlet weak var labelTitle: UILabel! @IBOutlet weak var labelInfo: UILabel! @IBOutlet weak var labelSubinfo: UILabel! + @IBOutlet weak var buttonMore: UIButton! + @IBOutlet weak var imageVisualEffect: UIVisualEffectView! @IBOutlet weak var iconsStackView: UIStackView! @@ -51,6 +54,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP override func prepareForReuse() { super.prepareForReuse() + initCell() } @@ -68,9 +72,11 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP imageStatus.image = nil imageFavorite.image = nil imageLocal.image = nil + labelTitle.text = "" labelInfo.text = "" labelSubinfo.text = "" + imageVisualEffect.layer.cornerRadius = 6 imageVisualEffect.clipsToBounds = true imageVisualEffect.alpha = 0.5 diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index d295348d9c..a74633155f 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -19,17 +19,19 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP @IBOutlet weak var imageStatus: UIImageView! @IBOutlet weak var imageFavorite: UIImageView! @IBOutlet weak var imageLocal: UIImageView! + @IBOutlet weak var imageShared: UIImageView! + @IBOutlet weak var imageMore: UIImageView! + @IBOutlet weak var labelTitle: UILabel! @IBOutlet weak var labelInfo: UILabel! - @IBOutlet weak var labelInfoSeparator: UILabel! @IBOutlet weak var labelSubinfo: UILabel! - @IBOutlet weak var imageShared: UIImageView! + @IBOutlet weak var labelInfoSeparator: UILabel! + @IBOutlet weak var tag0: UILabel! + @IBOutlet weak var tag1: UILabel! + @IBOutlet weak var buttonShared: UIButton! - @IBOutlet weak var imageMore: UIImageView! @IBOutlet weak var buttonMore: UIButton! @IBOutlet weak var separator: UIView! - @IBOutlet weak var tag0: UILabel! - @IBOutlet weak var tag1: UILabel! @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint! @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint! @@ -77,6 +79,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP override func prepareForReuse() { super.prepareForReuse() + initCell() } @@ -92,19 +95,25 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP imageStatus.image = nil imageFavorite.image = nil imageLocal.image = nil + imageShared.image = nil + imageMore.image = nil + imageSelect.image = nil + labelTitle.text = "" labelInfo.text = "" labelSubinfo.text = "" - imageShared.image = nil - imageMore.image = nil - separatorHeightConstraint.constant = 0.5 + labelInfoSeparator.text = "" tag0.text = "" tag1.text = "" - titleTrailingConstraint.constant = 90 - contentView.bringSubviewToFront(buttonMore) + separatorHeightConstraint.constant = 0.5 + buttonMore.menu = nil buttonMore.showsMenuAsPrimaryAction = true + + titleTrailingConstraint.constant = 90 + + contentView.bringSubviewToFront(buttonMore) } override func snapshotView(afterScreenUpdates afterUpdates: Bool) -> UIView? { @@ -123,7 +132,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP } } - // Allow the button to receive taps even with the long press gesture func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { let location = touch.location(in: contentView) return buttonMore.frame.contains(location) @@ -241,7 +249,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP view.removeFromSuperview() } } - } override func layoutSubviews() { From 2f594d2669e9e18b216390d8f3dafc49302973de Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sun, 15 Feb 2026 09:43:43 +0100 Subject: [PATCH 19/22] code Signed-off-by: Marino Faggiana --- iOSClient/Assistant/Models/NCAssistantModel.swift | 10 ++++++++++ .../Main/Collection Common/Cell/NCPhotoCell.swift | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/iOSClient/Assistant/Models/NCAssistantModel.swift b/iOSClient/Assistant/Models/NCAssistantModel.swift index a4f34f0a34..dd99f16704 100644 --- a/iOSClient/Assistant/Models/NCAssistantModel.swift +++ b/iOSClient/Assistant/Models/NCAssistantModel.swift @@ -60,6 +60,7 @@ class NCAssistantModel: ObservableObject { selectedTask = task isLoading = true + /* if useV2 { NextcloudKit.shared.textProcessingGetTasksV2(taskType: task.type ?? "", account: session.account, completion: { _, _, _, error in handle(task: task, error: error) @@ -71,6 +72,7 @@ class NCAssistantModel: ObservableObject { handle(task: taskV2, error: error) } } + */ func handle(task: AssistantTask?, error: NKError?) { self.isLoading = false @@ -87,6 +89,7 @@ class NCAssistantModel: ObservableObject { func scheduleTask(input: String) { isLoading = true + /* if useV2 { guard let selectedType else { return } NextcloudKit.shared.textProcessingScheduleV2(input: input, taskType: selectedType, account: session.account) { _, task, _, error in @@ -98,6 +101,7 @@ class NCAssistantModel: ObservableObject { handle(task: taskV2, error: error) } } + */ func handle(task: AssistantTask?, error: NKError?) { self.isLoading = false @@ -117,6 +121,7 @@ class NCAssistantModel: ObservableObject { func deleteTask(_ task: AssistantTask) { isLoading = true + /* if useV2 { NextcloudKit.shared.textProcessingDeleteTaskV2(taskId: task.id, account: session.account) { _, _, error in handle(task: task, error: error) @@ -126,6 +131,7 @@ class NCAssistantModel: ObservableObject { handle(task: task, error: error) } } + */ func handle(task: AssistantTask, error: NKError?) { self.isLoading = false @@ -148,6 +154,7 @@ class NCAssistantModel: ObservableObject { private func loadAllTypes() { isLoading = true + /* if useV2 { NextcloudKit.shared.textProcessingGetTypesV2(account: session.account) { _, types, _, error in handle(types: types, error: error) @@ -160,6 +167,7 @@ class NCAssistantModel: ObservableObject { handle(types: typesV2, error: error) } } + */ func handle(types: [TaskTypeData]?, error: NKError) { self.isLoading = false @@ -184,6 +192,7 @@ class NCAssistantModel: ObservableObject { private func loadAllTasks(appId: String = "assistant", type: TaskTypeData?) { isLoading = true + /* if useV2 { NextcloudKit.shared.textProcessingGetTasksV2(taskType: type?.id ?? "", account: session.account) { _, tasks, _, error in guard let tasks = tasks?.tasks.filter({ $0.appId == "assistant" }) else { return } @@ -195,6 +204,7 @@ class NCAssistantModel: ObservableObject { handle(tasks: NKTextProcessingTask.toV2(tasks: tasks).tasks, error: error) } } + */ func handle(tasks: [AssistantTask], error: NKError?) { isLoading = false diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index bc9317243b..f579d244fd 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -9,7 +9,6 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMain @IBOutlet weak var imageSelect: UIImageView! @IBOutlet weak var imageVisualEffect: UIVisualEffectView! - // Cell Protocol var metadata: tableMetadata? var previewImage: UIImageView? { get { return imageItem } @@ -18,6 +17,7 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMain override func prepareForReuse() { super.prepareForReuse() + initCell() } From 3c52d42bc47d88f4d78b8f0adffdef835537f112 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sun, 15 Feb 2026 09:48:16 +0100 Subject: [PATCH 20/22] clean Signed-off-by: Marino Faggiana --- .../NCCollectionViewCommon.swift | 159 +++++++++--------- 1 file changed, 83 insertions(+), 76 deletions(-) diff --git a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift index 909a54d013..e1a560361c 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewCommon.swift @@ -13,124 +13,131 @@ class NCCollectionViewCommon: UIViewController, NCAccountSettingsModelDelegate, @IBOutlet weak var collectionView: UICollectionView! - let database = NCManageDatabase.shared - let global = NCGlobal.shared - let utility = NCUtility() - let utilityFileSystem = NCUtilityFileSystem() - let imageCache = NCImageCache.shared - var dataSource = NCCollectionViewDataSource() - let networking = NCNetworking.shared - let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! - var pinchGesture: UIPinchGestureRecognizer = UIPinchGestureRecognizer() - - var autoUploadFileName = "" - var autoUploadDirectory = "" - let refreshControl = UIRefreshControl() - var searchController: UISearchController? - var backgroundImageView = UIImageView() - var serverUrl: String = "" - var isEditMode = false - var isDirectoryE2EE = false - var fileSelect: [String] = [] - var metadataFolder: tableMetadata? - var richWorkspaceText: String? - var sectionFirstHeader: NCSectionFirstHeader? - var sectionFirstHeaderEmptyData: NCSectionFirstHeaderEmptyData? + internal let database = NCManageDatabase.shared + internal let global = NCGlobal.shared + internal let utility = NCUtility() + internal let utilityFileSystem = NCUtilityFileSystem() + internal let imageCache = NCImageCache.shared + internal var dataSource = NCCollectionViewDataSource() + internal let networking = NCNetworking.shared + internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)! + internal var pinchGesture: UIPinchGestureRecognizer = UIPinchGestureRecognizer() + + internal var autoUploadFileName = "" + internal var autoUploadDirectory = "" + internal let refreshControl = UIRefreshControl() + internal var searchController: UISearchController? + internal var backgroundImageView = UIImageView() + internal var serverUrl: String = "" + internal var isEditMode = false + internal var isDirectoryE2EE = false + internal var fileSelect: [String] = [] + internal var metadataFolder: tableMetadata? + internal var richWorkspaceText: String? + internal var sectionFirstHeader: NCSectionFirstHeader? + internal var sectionFirstHeaderEmptyData: NCSectionFirstHeaderEmptyData? + // Layout - var layoutForView: NCDBLayoutForView? - var layoutForViewLayoutStore: String? - var listLayout = NCListLayout() - var gridLayout = NCGridLayout() - var mediaLayout = NCMediaLayout() - var layoutType = NCGlobal.shared.layoutList - - var tabBarSelect: NCCollectionViewCommonSelectTabBar? - var attributesZoomIn: UIMenuElement.Attributes = [] - var attributesZoomOut: UIMenuElement.Attributes = [] - var tipViewAccounts: EasyTipView? - var syncMetadatasTask: Task? + // + internal var layoutForView: NCDBLayoutForView? + internal var layoutForViewLayoutStore: String? + internal var listLayout = NCListLayout() + internal var gridLayout = NCGridLayout() + internal var mediaLayout = NCMediaLayout() + internal var layoutType = NCGlobal.shared.layoutList + + internal var tabBarSelect: NCCollectionViewCommonSelectTabBar? + + internal var attributesZoomIn: UIMenuElement.Attributes = [] + internal var attributesZoomOut: UIMenuElement.Attributes = [] + + internal var tipViewAccounts: EasyTipView? + internal var syncMetadatasTask: Task? + // Search - var isSearchingMode: Bool = false - var networkSearchInProgress: Bool = false - var searchOperationHandle = NKOperationHandle() - var searchTask: URLSessionTask? - var searchResultText: String? - var searchResultStore: String? + // + internal var isSearchingMode: Bool = false + internal var networkSearchInProgress: Bool = false + internal var searchOperationHandle = NKOperationHandle() + internal var searchTask: URLSessionTask? + internal var searchResultText: String? + internal var searchResultStore: String? // DECLARE - var layoutKey = "" - var titleCurrentFolder = "" - var titlePreviusFolder: String? - var enableSearchBar: Bool = false - var headerRichWorkspaceDisable: Bool = false - - var emptyImageName: String? - var emptyImageColors: [UIColor]? - var emptyTitle: String = "" - - var emptyDescription: String = "" - var emptyDataPortaitOffset: CGFloat = 0 - var emptyDataLandscapeOffset: CGFloat = -20 - - var lastScale: CGFloat = 1.0 - var currentScale: CGFloat = 1.0 - var maxColumns: Int { + // + internal var layoutKey = "" + internal var titleCurrentFolder = "" + internal var titlePreviusFolder: String? + internal var enableSearchBar: Bool = false + internal var headerRichWorkspaceDisable: Bool = false + + internal var emptyImageName: String? + internal var emptyImageColors: [UIColor]? + internal var emptyTitle: String = "" + + internal var emptyDescription: String = "" + internal var emptyDataPortaitOffset: CGFloat = 0 + internal var emptyDataLandscapeOffset: CGFloat = -20 + + internal var lastScale: CGFloat = 1.0 + internal var currentScale: CGFloat = 1.0 + internal var maxColumns: Int { let screenWidth = min(UIScreen.main.bounds.width, UIScreen.main.bounds.height) let column = Int(screenWidth / 44) return column } - var transitionColumns = false - var numberOfColumns: Int = 0 - var lastNumberOfColumns: Int = 0 + internal var transitionColumns = false + internal var numberOfColumns: Int = 0 + internal var lastNumberOfColumns: Int = 0 - let heightHeaderRecommendations: CGFloat = 160 - let heightHeaderSection: CGFloat = 30 + internal let heightHeaderRecommendations: CGFloat = 160 + internal let heightHeaderSection: CGFloat = 30 @MainActor - var session: NCSession.Session { + internal var session: NCSession.Session { NCSession.shared.getSession(controller: tabBarController) } - var isLayoutPhoto: Bool { + internal var isLayoutPhoto: Bool { layoutForView?.layout == global.layoutPhotoRatio || layoutForView?.layout == global.layoutPhotoSquare } - var isLayoutGrid: Bool { + internal var isLayoutGrid: Bool { layoutForView?.layout == global.layoutGrid } - var isLayoutList: Bool { + internal var isLayoutList: Bool { layoutForView?.layout == global.layoutList } - var showDescription: Bool { + internal var showDescription: Bool { !headerRichWorkspaceDisable && NCPreferences().showDescription } - var isRecommendationActived: Bool { + internal var isRecommendationActived: Bool { let capabilities = NCNetworking.shared.capabilities[session.account] ?? NKCapabilities.Capabilities() return self.serverUrl == self.utilityFileSystem.getHomeServer(session: self.session) && capabilities.recommendations } - var infoLabelsSeparator: String { + internal var infoLabelsSeparator: String { layoutForView?.layout == global.layoutList ? " - " : "" } @MainActor - var controller: NCMainTabBarController? { + internal var controller: NCMainTabBarController? { self.tabBarController as? NCMainTabBarController } - var mainNavigationController: NCMainNavigationController? { + internal var mainNavigationController: NCMainNavigationController? { self.navigationController as? NCMainNavigationController } - var sceneIdentifier: String { + internal var sceneIdentifier: String { (self.tabBarController as? NCMainTabBarController)?.sceneIdentifier ?? "" } - var isNumberOfItemsInAllSectionsNull: Bool { + internal var isNumberOfItemsInAllSectionsNull: Bool { var totalItems = 0 for section in 0.. Date: Sun, 15 Feb 2026 11:17:02 +0100 Subject: [PATCH 21/22] code Signed-off-by: Marino Faggiana --- Nextcloud.xcodeproj/project.pbxproj | 2 +- .../Collection Common/Cell/NCCellMain.swift | 114 +++++++++--------- .../Collection Common/Cell/NCGridCell.swift | 20 ++- .../Collection Common/Cell/NCListCell.swift | 39 ++++-- .../Collection Common/Cell/NCPhotoCell.swift | 18 +-- .../NCCollectionViewDownloadThumbnail.swift | 2 +- .../Networking/NCNetworking+WebDAV.swift | 4 +- iOSClient/Select/NCSelect.swift | 6 +- 8 files changed, 115 insertions(+), 90 deletions(-) diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index 59aa46a9a6..4b68394076 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -2458,9 +2458,9 @@ isa = PBXGroup; children = ( 370D26AE248A3D7A00121797 /* NCCellMain.swift */, + F78ACD4121903CE00088454D /* NCListCell.swift */, F78ACD3F21903CC20088454D /* NCGridCell.swift */, F751247A2C42919C00E63DB8 /* NCPhotoCell.swift */, - F78ACD4121903CE00088454D /* NCListCell.swift */, F78ACD4521903D010088454D /* NCGridCell.xib */, F78ACD4321903CF20088454D /* NCListCell.xib */, F751247B2C42919C00E63DB8 /* NCPhotoCell.xib */, diff --git a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift index 2735f872c5..82d5d1b68b 100644 --- a/iOSClient/Main/Collection Common/Cell/NCCellMain.swift +++ b/iOSClient/Main/Collection Common/Cell/NCCellMain.swift @@ -9,11 +9,11 @@ import RealmSwift protocol NCCellMainProtocol { var metadata: tableMetadata? {get set } - var avatarImage: UIImageView? { get } - var previewImage: UIImageView? { get set } - var imageLocal: UIImageView? { get set } - var imageStatus: UIImageView? { get set } - var labelInfo: UILabel? { get set } + var avatarImg: UIImageView? { get } + var previewImg: UIImageView? { get set } + var localImg: UIImageView? { get set } + var statusImg: UIImageView? { get set } + var infoLbl: UILabel? { get set } } @@ -22,23 +22,23 @@ extension NCCellMainProtocol { get { return nil } set {} } - var avatarImage: UIImageView? { + var avatarImg: UIImageView? { get { return nil } set {} } - var previewImage: UIImageView? { + var previewImg: UIImageView? { get { return nil } set {} } - var imageLocal: UIImageView? { + var localImg: UIImageView? { get { return nil } set {} } - var imageStatus: UIImageView? { + var statusImg: UIImageView? { get { return nil } set {} } - var labelInfo: UILabel? { + var infoLbl: UILabel? { get { return nil } set {} } @@ -50,34 +50,34 @@ extension NCCollectionViewCommon { metadata: tableMetadata, a11yValues: inout [String]) { if metadata.isLivePhoto { - cell.imageStatus?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) + cell.statusImg?.image = utility.loadImage(named: "livephoto", colors: [NCBrandColor.shared.iconImageColor]) a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: "")) } else if metadata.isVideo { - cell.imageStatus?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) + cell.statusImg?.image = utility.loadImage(named: "play.circle.fill", colors: [.systemBackgroundInverted, .systemGray5]) } switch metadata.status { case global.metadataStatusWaitCreateFolder: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") + cell.statusImg?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.infoLbl?.text = NSLocalizedString("_status_wait_create_folder_", comment: "") case global.metadataStatusWaitFavorite: - cell.imageStatus?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_favorite_", comment: "") + cell.statusImg?.image = utility.loadImage(named: "star.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.infoLbl?.text = NSLocalizedString("_status_wait_favorite_", comment: "") case global.metadataStatusWaitCopy: - cell.imageStatus?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_copy_", comment: "") + cell.statusImg?.image = utility.loadImage(named: "c.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.infoLbl?.text = NSLocalizedString("_status_wait_copy_", comment: "") case global.metadataStatusWaitMove: - cell.imageStatus?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_move_", comment: "") + cell.statusImg?.image = utility.loadImage(named: "m.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.infoLbl?.text = NSLocalizedString("_status_wait_move_", comment: "") case global.metadataStatusWaitRename: - cell.imageStatus?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) - cell.labelInfo?.text = NSLocalizedString("_status_wait_rename_", comment: "") + cell.statusImg?.image = utility.loadImage(named: "a.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.infoLbl?.text = NSLocalizedString("_status_wait_rename_", comment: "") case global.metadataStatusWaitDownload: - cell.imageStatus?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) + cell.statusImg?.image = utility.loadImage(named: "arrow.triangle.2.circlepath", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloading: - cell.imageStatus?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.statusImg?.image = utility.loadImage(named: "arrowshape.down.circle", colors: NCBrandColor.shared.iconImageMultiColors) case global.metadataStatusDownloadError, global.metadataStatusUploadError: - cell.imageStatus?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) + cell.statusImg?.image = utility.loadImage(named: "exclamationmark.circle", colors: NCBrandColor.shared.iconImageMultiColors) default: break } @@ -90,34 +90,34 @@ extension NCCollectionViewCommon { let tblDirectory = database.getTableDirectory(ocId: metadata.ocId) if metadata.e2eEncrypted { - cell.previewImage?.image = imageCache.getFolderEncrypted(account: metadata.account) + cell.previewImg?.image = imageCache.getFolderEncrypted(account: metadata.account) } else if isShare { - cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account) + cell.previewImg?.image = imageCache.getFolderSharedWithMe(account: metadata.account) } else if !metadata.shareType.isEmpty { metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) ? - (cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account)) : - (cell.previewImage?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) + (cell.previewImg?.image = imageCache.getFolderPublic(account: metadata.account)) : + (cell.previewImg?.image = imageCache.getFolderSharedWithMe(account: metadata.account)) } else if !metadata.shareType.isEmpty && metadata.shareType.contains(NKShare.ShareType.publicLink.rawValue) { - cell.previewImage?.image = imageCache.getFolderPublic(account: metadata.account) + cell.previewImg?.image = imageCache.getFolderPublic(account: metadata.account) } else if metadata.mountType == "group" { - cell.previewImage?.image = imageCache.getFolderGroup(account: metadata.account) + cell.previewImg?.image = imageCache.getFolderGroup(account: metadata.account) } else if isMounted { - cell.previewImage?.image = imageCache.getFolderExternal(account: metadata.account) + cell.previewImg?.image = imageCache.getFolderExternal(account: metadata.account) } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.previewImage?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) + cell.previewImg?.image = imageCache.getFolderAutomaticUpload(account: metadata.account) } else { - cell.previewImage?.image = imageCache.getFolder(account: metadata.account) + cell.previewImg?.image = imageCache.getFolder(account: metadata.account) } // Local image: offline metadata.isOffline = tblDirectory?.offline ?? false if metadata.isOffline { - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + cell.localImg?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) } // color folder - cell.previewImage?.image = cell.previewImage?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) + cell.previewImg?.image = cell.previewImg?.image?.colorizeFolder(metadata: metadata, tblDirectory: tblDirectory) } func cellMainFile(cell: NCCellMainProtocol, @@ -126,59 +126,59 @@ extension NCCollectionViewCommon { let tableLocalFile = database.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) if metadata.hasPreviewBorder { - cell.previewImage?.layer.borderWidth = 0.2 - cell.previewImage?.layer.borderColor = UIColor.lightGray.cgColor + cell.previewImg?.layer.borderWidth = 0.2 + cell.previewImg?.layer.borderColor = UIColor.lightGray.cgColor } if metadata.name == global.appName { let ext = global.getSizeExtension(column: self.numberOfColumns) if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImage?.image = image + cell.previewImg?.image = image } else if let image = utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) { - cell.previewImage?.image = image + cell.previewImg?.image = image } - if cell.previewImage?.image == nil { + if cell.previewImg?.image == nil { if metadata.iconName.isEmpty { - cell.previewImage?.image = NCImageCache.shared.getImageFile() + cell.previewImg?.image = NCImageCache.shared.getImageFile() } else { - cell.previewImage?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + cell.previewImg?.image = utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } } } else { // APP NAME - UNIFIED SEARCH switch metadata.iconName { case let str where str.contains("contacts"): - cell.previewImage?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImg?.image = utility.loadImage(named: "person.crop.rectangle.stack", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("conversation"): - cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + cell.previewImg?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) case let str where str.contains("calendar"): - cell.previewImage?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImg?.image = utility.loadImage(named: "calendar", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("deck"): - cell.previewImage?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImg?.image = utility.loadImage(named: "square.stack.fill", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("mail"): - cell.previewImage?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImg?.image = utility.loadImage(named: "mail", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("talk"): - cell.previewImage?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) + cell.previewImg?.image = UIImage(named: "talk-template")!.image(color: NCBrandColor.shared.getElement(account: metadata.account)) case let str where str.contains("confirm"): - cell.previewImage?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImg?.image = utility.loadImage(named: "arrow.right", colors: [NCBrandColor.shared.iconImageColor]) case let str where str.contains("pages"): - cell.previewImage?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImg?.image = utility.loadImage(named: "doc.richtext", colors: [NCBrandColor.shared.iconImageColor]) default: - cell.previewImage?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) + cell.previewImg?.image = utility.loadImage(named: "doc", colors: [NCBrandColor.shared.iconImageColor]) } if !metadata.iconUrl.isEmpty { if let ownerId = getAvatarFromIconUrl(metadata: metadata) { let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: ownerId) if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.previewImage?.image = image + cell.previewImg?.image = image } else { self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in if let image { - cell.previewImage?.image = image + cell.previewImg?.image = image NCImageCache.shared.addImageCache(image: image, key: fileName) } else { - cell.previewImage?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) + cell.previewImg?.image = self.utility.loadUserImage(for: ownerId, displayName: nil, urlBase: metadata.urlBase) } if !(tblAvatar?.loaded ?? false), @@ -196,9 +196,9 @@ extension NCCollectionViewCommon { if metadata.isOffline { a11yValues.append(NSLocalizedString("_offline_", comment: "")) - cell.imageLocal?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) + cell.localImg?.image = imageCache.getImageOfflineFlag(colors: [.systemBackground, .systemGreen]) } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.imageLocal?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) + cell.localImg?.image = imageCache.getImageLocal(colors: [.systemBackground, .systemGreen]) } } diff --git a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift index 5a5d99bf09..50f4b187f3 100644 --- a/iOSClient/Main/Collection Common/Cell/NCGridCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCGridCell.swift @@ -36,10 +36,22 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } - var previewImage: UIImageView? { + var previewImg: UIImageView? { get { return imageItem } set { imageItem = newValue } } + var localImg: UIImageView? { + get { return imageLocal } + set { imageLocal = newValue } + } + var statusImg: UIImageView? { + get { return imageStatus } + set { imageStatus = newValue } + } + var infoLbl: UILabel? { + get { return labelInfo } + set { labelInfo = newValue } + } override func awakeFromNib() { super.awakeFromNib() @@ -200,12 +212,12 @@ extension NCCollectionViewCommon { let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) // CONTENT MODE - cell.previewImage?.layer.borderWidth = 0 + cell.previewImg?.layer.borderWidth = 0 if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { - cell.previewImage?.contentMode = .scaleAspectFill + cell.previewImg?.contentMode = .scaleAspectFill } else { - cell.previewImage?.contentMode = .scaleAspectFit + cell.previewImg?.contentMode = .scaleAspectFit } guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index a74633155f..df8de370c8 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -45,13 +45,26 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMainP delegate?.openContextMenu(with: metadata, button: buttonMore, sender: self) /* preconfigure UIMenu with each metadata */ } } - var avatarImage: UIImageView? { - return imageShared + var avatarImg: UIImageView? { + get { return imageShared } + set { imageShared = newValue } } - var previewImage: UIImageView? { + var previewImg: UIImageView? { get { return imageItem } set { imageItem = newValue } } + var localImg: UIImageView? { + get { return imageLocal } + set { imageLocal = newValue } + } + var statusImg: UIImageView? { + get { return imageStatus } + set { imageStatus = newValue } + } + var infoLbl: UILabel? { + get { return labelInfo } + set { labelInfo = newValue } + } override var accessibilityIdentifier: String? { get { @@ -390,13 +403,13 @@ extension NCCollectionViewCommon { let existsImagePreview = utilityFileSystem.fileProviderStorageImageExists(metadata.ocId, etag: metadata.etag, userId: metadata.userId, urlBase: metadata.urlBase) // CONTENT MODE - cell.avatarImage?.contentMode = .center - cell.previewImage?.layer.borderWidth = 0 + cell.avatarImg?.contentMode = .center + cell.previewImg?.layer.borderWidth = 0 if existsImagePreview && layoutForView?.layout != global.layoutPhotoRatio { - cell.previewImage?.contentMode = .scaleAspectFill + cell.previewImg?.contentMode = .scaleAspectFill } else { - cell.previewImage?.contentMode = .scaleAspectFit + cell.previewImg?.contentMode = .scaleAspectFit } guard let metadata = self.dataSource.getMetadata(indexPath: indexPath) else { @@ -468,17 +481,17 @@ extension NCCollectionViewCommon { if !metadata.ownerId.isEmpty, metadata.ownerId != metadata.userId { let fileName = NCSession.shared.getFileName(urlBase: metadata.urlBase, user: metadata.ownerId) if let image = NCImageCache.shared.getImageCache(key: fileName) { - cell.avatarImage?.contentMode = .scaleAspectFill - cell.avatarImage?.image = image + cell.avatarImg?.contentMode = .scaleAspectFill + cell.avatarImg?.image = image } else { self.database.getImageAvatarLoaded(fileName: fileName) { image, tblAvatar in if let image { - cell.avatarImage?.contentMode = .scaleAspectFill - cell.avatarImage?.image = image + cell.avatarImg?.contentMode = .scaleAspectFill + cell.avatarImg?.image = image NCImageCache.shared.addImageCache(image: image, key: fileName) } else { - cell.avatarImage?.contentMode = .scaleAspectFill - cell.avatarImage?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) + cell.avatarImg?.contentMode = .scaleAspectFill + cell.avatarImg?.image = self.utility.loadUserImage(for: metadata.ownerId, displayName: metadata.ownerDisplayName, urlBase: metadata.urlBase) } if !(tblAvatar?.loaded ?? false), diff --git a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift index f579d244fd..5c67a1dddc 100644 --- a/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCPhotoCell.swift @@ -10,7 +10,7 @@ class NCPhotoCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellMain @IBOutlet weak var imageVisualEffect: UIVisualEffectView! var metadata: tableMetadata? - var previewImage: UIImageView? { + var previewImg: UIImageView? { get { return imageItem } set { imageItem = newValue } } @@ -65,11 +65,11 @@ extension NCCollectionViewCommon { // Image // if let image = NCImageCache.shared.getImageCache(ocId: metadata.ocId, etag: metadata.etag, ext: ext) { - cell.previewImage?.image = image - cell.previewImage?.contentMode = .scaleAspectFill + cell.previewImg?.image = image + cell.previewImg?.contentMode = .scaleAspectFill } else { if isPinchGestureActive || ext == global.previewExt512 || ext == global.previewExt1024 { - cell.previewImage?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) + cell.previewImg?.image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: ext, userId: metadata.userId, urlBase: metadata.urlBase) } DispatchQueue.global(qos: .userInteractive).async { @@ -77,16 +77,16 @@ extension NCCollectionViewCommon { if let image { self.imageCache.addImageCache(ocId: metadata.ocId, etag: metadata.etag, image: image, ext: ext, cost: indexPath.row) DispatchQueue.main.async { - cell.previewImage?.image = image - cell.previewImage?.contentMode = .scaleAspectFill + cell.previewImg?.image = image + cell.previewImg?.contentMode = .scaleAspectFill } } else { DispatchQueue.main.async { - cell.previewImage?.contentMode = .scaleAspectFit + cell.previewImg?.contentMode = .scaleAspectFit if metadata.iconName.isEmpty { - cell.previewImage?.image = NCImageCache.shared.getImageFile() + cell.previewImg?.image = NCImageCache.shared.getImageFile() } else { - cell.previewImage?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + cell.previewImg?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } } } diff --git a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift index ccc36af656..6f705c9444 100644 --- a/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift +++ b/iOSClient/Main/Collection Common/NCCollectionViewDownloadThumbnail.swift @@ -43,7 +43,7 @@ class NCCollectionViewDownloadThumbnail: ConcurrentOperation, @unchecked Sendabl Task { @MainActor in for case let cell as NCCellMainProtocol in collectionView.visibleCells where cell.metadata?.ocId == self.metadata.ocId { - if let previewImage = cell.previewImage { + if let previewImage = cell.previewImg { previewImage.contentMode = .scaleAspectFill if self.metadata.hasPreviewBorder { diff --git a/iOSClient/Networking/NCNetworking+WebDAV.swift b/iOSClient/Networking/NCNetworking+WebDAV.swift index 08ae57c4de..9e761710d7 100644 --- a/iOSClient/Networking/NCNetworking+WebDAV.swift +++ b/iOSClient/Networking/NCNetworking+WebDAV.swift @@ -882,9 +882,9 @@ class NCOperationDownloadAvatar: ConcurrentOperation, @unchecked Sendable { let visibleCells: [UIView] = (self.view as? UICollectionView)?.visibleCells ?? (self.view as? UITableView)?.visibleCells ?? [] for case let cell as NCCellMainProtocol in visibleCells { if self.user == cell.metadata?.ownerId { - if self.isPreviewImage, let previewImage = cell.previewImage { + if self.isPreviewImage, let previewImage = cell.previewImg { UIView.transition(with: previewImage, duration: 0.75, options: .transitionCrossDissolve, animations: { previewImage.image = image}, completion: nil) - } else if let avatarImage = cell.avatarImage { + } else if let avatarImage = cell.avatarImg { UIView.transition(with: avatarImage, duration: 0.75, options: .transitionCrossDissolve, animations: { avatarImage.image = image}, completion: nil) } break diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 83ec7863bf..730664e2cb 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -337,12 +337,12 @@ extension NCSelect: UICollectionViewDataSource { // Thumbnail if !metadata.directory { if let image = self.utility.getImage(ocId: metadata.ocId, etag: metadata.etag, ext: NCGlobal.shared.previewExt512, userId: metadata.userId, urlBase: metadata.urlBase) { - (cell as? NCListCell)?.previewImage?.image = image + (cell as? NCListCell)?.previewImg?.image = image } else { if metadata.iconName.isEmpty { - (cell as? NCListCell)?.previewImage?.image = NCImageCache.shared.getImageFile() + (cell as? NCListCell)?.previewImg?.image = NCImageCache.shared.getImageFile() } else { - (cell as? NCListCell)?.previewImage?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) + (cell as? NCListCell)?.previewImg?.image = self.utility.loadImage(named: metadata.iconName, useTypeIconFile: true, account: metadata.account) } if metadata.hasPreview, metadata.status == NCGlobal.shared.metadataStatusNormal { From 13296428c9a2d42112bab2573f52393b6b98f2b7 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Sun, 15 Feb 2026 13:33:10 +0100 Subject: [PATCH 22/22] ipad fix menu Signed-off-by: Marino Faggiana --- .../Main/NCMainNavigationController.swift | 140 ++++++++---------- 1 file changed, 58 insertions(+), 82 deletions(-) diff --git a/iOSClient/Main/NCMainNavigationController.swift b/iOSClient/Main/NCMainNavigationController.swift index edf171945f..3b7a5d7a1d 100644 --- a/iOSClient/Main/NCMainNavigationController.swift +++ b/iOSClient/Main/NCMainNavigationController.swift @@ -40,44 +40,26 @@ class NCMainNavigationController: UINavigationController, UINavigationController let notificationsButtonTag = 102 let transfersButtonTag = 103 - lazy var menuButton: UIButton = { - let button = UIButton(type: .system) - return button - }() - var menuBarButtonItem: UIBarButtonItem { - let item = UIBarButtonItem(customView: menuButton) + lazy var menuBarButtonItem: UIBarButtonItem = { + let item = UIBarButtonItem() item.tag = menuButtonTag return item - } - lazy var assistantButton: UIButton = { - let button = UIButton(type: .system) - return button }() - var assistantButtonItem: UIBarButtonItem { - let item = UIBarButtonItem(customView: assistantButton) + lazy var assistantButtonItem: UIBarButtonItem = { + let item = UIBarButtonItem() item.tag = assistantButtonTag return item - } - - lazy var notificationsButton: UIButton = { - let button = UIButton(type: .system) - return button }() - var notificationsButtonItem: UIBarButtonItem { - let item = UIBarButtonItem(customView: notificationsButton) + lazy var notificationsButtonItem: UIBarButtonItem = { + let item = UIBarButtonItem() item.tag = notificationsButtonTag return item - } - - lazy var transfersButton: UIButton = { - let button = UIButton(type: .system) - return button }() - var transfersButtonItem: UIBarButtonItem { - let item = UIBarButtonItem(customView: transfersButton) + lazy var transfersButtonItem: UIBarButtonItem = { + let item = UIBarButtonItem() item.tag = transfersButtonTag return item - } + }() // MARK: - View Life Cycle @@ -89,35 +71,37 @@ class NCMainNavigationController: UINavigationController, UINavigationController setNavigationBarHidden(false, animated: true) Task { - menuButton.setImage(UIImage(systemName: "ellipsis"), for: .normal) - menuButton.tintColor = NCBrandColor.shared.iconImageColor - menuButton.menu = await createRightMenu() - menuButton.showsMenuAsPrimaryAction = true + menuBarButtonItem.image = UIImage(systemName: "ellipsis") + menuBarButtonItem.tintColor = NCBrandColor.shared.iconImageColor + menuBarButtonItem.menu = await createRightMenu() } - assistantButton.setImage(UIImage(systemName: "sparkles"), for: .normal) - assistantButton.tintColor = NCBrandColor.shared.iconImageColor - assistantButton.addAction(UIAction(handler: { _ in + assistantButtonItem.image = UIImage(systemName: "sparkles") + assistantButtonItem.title = NSLocalizedString("_assistant_", comment: "") + assistantButtonItem.tintColor = NCBrandColor.shared.iconImageColor + assistantButtonItem.primaryAction = UIAction(handler: { _ in let assistant = NCAssistant() .environmentObject(NCAssistantModel(controller: self.controller)) let hostingController = UIHostingController(rootView: assistant) self.present(hostingController, animated: true, completion: nil) - }), for: .touchUpInside) + }) - notificationsButton.setImage(UIImage(systemName: "bell.fill"), for: .normal) - notificationsButton.tintColor = NCBrandColor.shared.iconImageColor - notificationsButton.addAction(UIAction(handler: { _ in + notificationsButtonItem.image = UIImage(systemName: "bell.fill") + notificationsButtonItem.title = NSLocalizedString("_notifications_", comment: "") + notificationsButtonItem.tintColor = NCBrandColor.shared.iconImageColor + notificationsButtonItem.primaryAction = UIAction(handler: { _ in if let navigationController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? UINavigationController, let viewController = navigationController.topViewController as? NCNotification { viewController.modalPresentationStyle = .pageSheet viewController.session = self.session self.present(navigationController, animated: true, completion: nil) } - }), for: .touchUpInside) + }) - transfersButton.setImage(UIImage(systemName: "arrow.left.arrow.right.circle.fill"), for: .normal) - transfersButton.tintColor = NCBrandColor.shared.iconImageColor - transfersButton.addAction(UIAction(handler: { _ in + transfersButtonItem.image = UIImage(systemName: "arrow.left.arrow.right.circle.fill") + transfersButtonItem.title = NSLocalizedString("_transfers_", comment: "") + transfersButtonItem.tintColor = NCBrandColor.shared.iconImageColor + transfersButtonItem.primaryAction = UIAction(handler: { _ in let rootView = TransfersView(session: self.session, onClose: { [weak self] in self?.dismiss(animated: true) }) @@ -125,7 +109,7 @@ class NCMainNavigationController: UINavigationController, UINavigationController hosting.modalPresentationStyle = .pageSheet self.present(hosting, animated: true) - }), for: .touchUpInside) + }) // PLUS BUTTON ONLY IN FILES let widthAnchor: CGFloat @@ -186,8 +170,10 @@ class NCMainNavigationController: UINavigationController, UINavigationController } else { _ = await NextcloudKit.shared.getNotificationsAsync(account: account) { task in Task { - let identifier = await NCNetworking.shared.networkingTasks.createIdentifier(account: account, - name: "getNotifications") + let identifier = await NCNetworking.shared.networkingTasks.createIdentifier( + account: account, + name: "getNotifications" + ) await NCNetworking.shared.networkingTasks.track(identifier: identifier, task: task) } } @@ -612,10 +598,8 @@ class NCMainNavigationController: UINavigationController, UINavigationController func createRightMenu() async -> UIMenu? { return nil } func updateRightMenu() async { - if let rightBarButtonItems = topViewController?.navigationItem.rightBarButtonItems, - let menuBarButtonItem = rightBarButtonItems.first(where: { $0.tag == menuButtonTag }), - let menuButton = menuBarButtonItem.customView as? UIButton { - menuButton.menu = await createRightMenu() + if topViewController?.navigationItem.rightBarButtonItems?.first(where: { $0.tag == menuButtonTag }) != nil { + menuBarButtonItem.menu = await createRightMenu() } } @@ -869,11 +853,10 @@ class NCMainNavigationController: UINavigationController, UINavigationController func setRightItemColor(tag: Int, to color: UIColor) { guard let items = topViewController?.navigationItem.rightBarButtonItems, - let item = items.first(where: { $0.tag == tag }), - let button = item.customView as? UIButton + let item = items.first(where: { $0.tag == tag }) else { return } - applyTint(button, color: color) + applyTint(item, color: color) } /// Changes the tint color of all right bar button items currently visible @@ -884,9 +867,7 @@ class NCMainNavigationController: UINavigationController, UINavigationController guard let items = topViewController?.navigationItem.rightBarButtonItems else { return } for item in items { - if let button = item.customView as? UIButton { - applyTint(button, color: color) - } + applyTint(item, color: color) } } @@ -902,11 +883,10 @@ class NCMainNavigationController: UINavigationController, UINavigationController func setLeftItemColor(tag: Int, to color: UIColor) { guard let items = topViewController?.navigationItem.leftBarButtonItems, - let item = items.first(where: { $0.tag == tag }), - let button = item.customView as? UIButton + let item = items.first(where: { $0.tag == tag }) else { return } - applyTint(button, color: color) + applyTint(item, color: color) } /// Changes the tint color of all left bar button items currently visible @@ -917,9 +897,7 @@ class NCMainNavigationController: UINavigationController, UINavigationController guard let items = topViewController?.navigationItem.leftBarButtonItems else { return } for item in items { - if let button = item.customView as? UIButton { - applyTint(button, color: color) - } + applyTint(item, color: color) } } @@ -943,35 +921,33 @@ class NCMainNavigationController: UINavigationController, UINavigationController } } + @MainActor + private func applyTint(_ item: UIBarButtonItem, color: UIColor) { + if let button = item.customView as? UIButton { + applyTint(button, color: color) + } else { + item.tintColor = color + } + } + /// Updates the tint color of all preloaded and currently visible right bar buttons. /// - Parameter color: The UIColor to be applied to all right bar button items. @MainActor func updateRightBarButtonsTint(to color: UIColor) { - let rightButtons: [UIButton] = [ - menuButton, - assistantButton, - notificationsButton, - transfersButton + let rightItems: [UIBarButtonItem] = [ + menuBarButtonItem, + assistantButtonItem, + notificationsButtonItem, + transfersButtonItem ] - // Apply color to preloaded button instances - for button in rightButtons { - if var cfg = button.configuration { - cfg.baseForegroundColor = color - button.configuration = cfg - } else { - button.tintColor = color - button.setTitleColor(color, for: .normal) - } + for item in rightItems { + applyTint(item, color: color) } - // Update also those already visible in the navigation bar - if let rightItems = topViewController?.navigationItem.rightBarButtonItems { - for item in rightItems { - if let button = item.customView as? UIButton { - button.tintColor = color - button.setTitleColor(color, for: .normal) - } + if let visibleItems = topViewController?.navigationItem.rightBarButtonItems { + for item in visibleItems { + applyTint(item, color: color) } } }