From 7e72d14efcb69c3deb16f80887943e44ce3fbb4b Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Tue, 28 Nov 2023 11:37:14 +0530 Subject: [PATCH 1/4] nmc 2157 - move copy customisation --- .../NextcloudUnitTests/MoveAndCopyTests.swift | 106 ++++ .../Collection Common/Cell/NCListCell.swift | 2 - iOSClient/Select/NCSelect.swift | 468 +++++++++++++----- .../Select/NCSelectCommandViewCopyMove.xib | 113 +++-- 4 files changed, 497 insertions(+), 192 deletions(-) create mode 100644 Tests/NextcloudUnitTests/MoveAndCopyTests.swift diff --git a/Tests/NextcloudUnitTests/MoveAndCopyTests.swift b/Tests/NextcloudUnitTests/MoveAndCopyTests.swift new file mode 100644 index 0000000000..bd674a472f --- /dev/null +++ b/Tests/NextcloudUnitTests/MoveAndCopyTests.swift @@ -0,0 +1,106 @@ +// +// MoveAndCopyTests.swift +// NextcloudTests +// +// Created by A200073704 on 05/06/23. +// Copyright © 2023 Marino Faggiana. All rights reserved. +// + +@testable import Nextcloud +import XCTest +import NextcloudKit + + + class MoveAndCopyTests: XCTestCase { + + var view : NCSelectCommandView? + var viewController : NCSelect? + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + let storyboard = UIStoryboard(name: "NCSelect", bundle: nil) + if let navigationController = storyboard.instantiateInitialViewController() as? UINavigationController { + let viewController = navigationController.topViewController as? NCSelect + + let _ = viewController?.view + viewController?.loadViewIfNeeded() + } + view = NCSelectCommandView() + + } + + override func setUp() { + super.setUp() + let nib = Bundle.main.loadNibNamed("NCSelectCommandViewCopyMove", owner: nil, options: nil) + view = nib?.first as? NCSelectCommandView + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + + viewController = nil + view = nil + + } + + func testCreateFolderButton() { + + let image: Void? = view?.createFolderButton?.setImage(UIImage(named: "addFolder")?.withTintColor(UIColor.label), for: .normal) + + XCTAssertNotNil(image) + } + + func testOverwriteSwitch() { + + let mySwitch = view?.overwriteSwitch + + XCTAssertNotNil(mySwitch) + + } + + func testCopyButton() { + + let copy = view?.copyButton + + XCTAssertNotNil(copy) + } + + + func testOverwriteSwitchAlwaysOn() { + + XCTAssertTrue(view?.overwriteSwitch?.isOn ?? false, "Overwrite Switch should always be on") + } + + func testCopyButtonandMoveButtonCondition() { + + // Disable copy and move + view?.copyButton?.isEnabled = false + view?.moveButton?.isEnabled = false + + // Creating a test item + let item = tableMetadata() + item.serverUrl = "serverUrl" // Set the serverUrl property of the item + + let items: [tableMetadata] = [item] + + // Update the items in the view controller + viewController?.items = items + + // Verify that the copy and move buttons are still disabled + XCTAssertFalse(view?.copyButton?.isEnabled ?? true, "Copy Button should remain disabled when items.first matches the condition") + XCTAssertFalse(view?.moveButton?.isEnabled ?? true, "Move Button should remain disabled when items.first matches the condition") + + // Enable copy and move + view?.copyButton?.isEnabled = true + view?.moveButton?.isEnabled = true + + // Update the items in the view controller + viewController?.items = [] // Empty items + + // Verify that the copyButton is still enabled + XCTAssertTrue(view?.copyButton?.isEnabled ?? false, "Copy Button should remain enabled when items.first doesn't match the condition") + XCTAssertTrue(view?.moveButton?.isEnabled ?? false, "Move Button should remain enabled when items.first doesn't match the condition") + } + +} diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index d27dc6aa09..db8c9ef791 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -239,7 +239,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto if status { imageItemLeftConstraint.constant = 45 imageSelect.isHidden = false - imageShared.isHidden = true imageMore.isHidden = true buttonShared.isHidden = true buttonMore.isHidden = true @@ -247,7 +246,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto } else { imageItemLeftConstraint.constant = 10 imageSelect.isHidden = true - imageShared.isHidden = false imageMore.isHidden = false buttonShared.isHidden = false buttonMore.isHidden = false diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index c1388caa64..ff5b600a67 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -26,10 +26,10 @@ import SwiftUI import NextcloudKit @objc protocol NCSelectDelegate { - @objc func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool) + @objc func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) } -class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresentationControllerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate { +class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresentationControllerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, NCEmptyDataSetDelegate { @IBOutlet private var collectionView: UICollectionView! @IBOutlet private var buttonCancel: UIBarButtonItem! @@ -56,20 +56,30 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent @objc var enableSelectFile = false @objc var type = "" @objc var items: [tableMetadata] = [] + @objc var selectIndexPath: [IndexPath] = [] var titleCurrentFolder = NCBrandOptions.shared.brand var serverUrl = "" // ------------------------------------------------------------- private var dataSourceTask: URLSessionTask? + private var emptyDataSet: NCEmptyDataSet? + private let layoutKey = NCGlobal.shared.layoutViewMove private var serverUrlPush = "" private var metadataFolder = tableMetadata() + private var isEditMode = false + private var isSearching = false + private var networkInProgress = false + private var selectOcId: [String] = [] private var overwrite = true private var dataSource = NCDataSource() internal var richWorkspaceText: String? + private var layoutForView: NCDBLayoutForView? internal var headerMenu: NCSectionHeaderMenu? private var autoUploadFileName = "" private var autoUploadDirectory = "" + private var listLayout: NCListLayout! + private var gridLayout: NCGridLayout! private var backgroundImageView = UIImageView() private var activeAccount: tableAccount! private let window = UIApplication.shared.connectedScenes.flatMap { ($0 as? UIWindowScene)?.windows ?? [] }.first { $0.isKeyWindow } @@ -89,10 +99,9 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent // Cell collectionView.register(UINib(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell") - collectionView.collectionViewLayout = NCListLayout() + collectionView.register(UINib(nibName: "NCGridCell", bundle: nil), forCellWithReuseIdentifier: "gridCell") // Header - collectionView.register(UINib(nibName: "NCSectionHeaderEmptyData", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderEmptyData") collectionView.register(UINib(nibName: "NCSectionHeaderMenu", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderMenu") // Footer @@ -100,9 +109,17 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent collectionView.alwaysBounceVertical = true collectionView.backgroundColor = .systemBackground + listLayout = NCListLayout() + gridLayout = NCGridLayout() + buttonCancel.title = NSLocalizedString("_cancel_", comment: "") + buttonCancel.tintColor = NCBrandColor.shared.customer + bottomContraint?.constant = window?.rootViewController?.view.safeAreaInsets.bottom ?? 0 + // Empty + emptyDataSet = NCEmptyDataSet(view: collectionView, offset: NCGlobal.shared.heightButtonsView, delegate: self) + // Type of command view if typeOfCommandView == .select || typeOfCommandView == .selectCreateFolder { if typeOfCommandView == .select { @@ -143,8 +160,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent NotificationCenter.default.addObserver(self, selector: #selector(createFolder(_:)), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterCreateFolder), object: nil) } - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) self.navigationItem.title = titleCurrentFolder @@ -156,8 +173,24 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent // get auto upload folder autoUploadFileName = NCManageDatabase.shared.getAccountAutoUploadFileName() autoUploadDirectory = NCManageDatabase.shared.getAccountAutoUploadDirectory(urlBase: activeAccount.urlBase, userId: activeAccount.userId, account: activeAccount.account) - + layoutForView = NCManageDatabase.shared.getLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl) + gridLayout.itemForLine = CGFloat(layoutForView?.itemForLine ?? 3) + + if layoutForView?.layout == NCGlobal.shared.layoutList { + collectionView.collectionViewLayout = listLayout + } else { + collectionView.collectionViewLayout = gridLayout + } loadDatasource(withLoadFolder: true) + if let item = items.first, item.serverUrl == serverUrl { + selectCommandViewSelect?.moveButton?.isEnabled = false + selectCommandViewSelect?.copyButton?.isEnabled = false + selectCommandViewSelect?.copyButton?.alpha = 0.5 + } else { + selectCommandViewSelect?.moveButton?.isEnabled = true + selectCommandViewSelect?.copyButton?.isEnabled = true + selectCommandViewSelect?.copyButton?.alpha = 1.0 + } } override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { @@ -186,6 +219,25 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent pushMetadata(metadata) } + // MARK: - Empty + + func emptyDataSetView(_ view: NCEmptyView) { + + if self.dataSourceTask?.state == .running { + view.emptyImage.image = UIImage(named: "networkInProgress")?.image(color: .gray, size: UIScreen.main.bounds.width) + view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "") + view.emptyDescription.text = "" + } else { + view.emptyImage.image = UIImage(named: "folder") + if includeImages { + view.emptyTitle.text = NSLocalizedString("_files_no_files_", comment: "") + } else { + view.emptyTitle.text = NSLocalizedString("_files_no_folders_", comment: "") + } + view.emptyDescription.text = "" + } + } + // MARK: ACTION @IBAction func actionCancel(_ sender: UIBarButtonItem) { @@ -193,17 +245,17 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent } func selectButtonPressed(_ sender: UIButton) { - delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, overwrite: overwrite, copy: false, move: false) + delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: false, move: false) self.dismiss(animated: true, completion: nil) } func copyButtonPressed(_ sender: UIButton) { - delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, overwrite: overwrite, copy: true, move: false) + delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: true, move: false) self.dismiss(animated: true, completion: nil) } func moveButtonPressed(_ sender: UIButton) { - delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, overwrite: overwrite, copy: false, move: true) + delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadataFolder, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: false, move: true) self.dismiss(animated: true, completion: nil) } @@ -216,6 +268,39 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent overwrite = sender.isOn } + // MARK: TAP EVENT + func tapButtonSwitch(_ sender: Any) { + + if layoutForView?.layout == NCGlobal.shared.layoutGrid { + + // list layout + headerMenu?.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "") + layoutForView?.layout = NCGlobal.shared.layoutList + NCManageDatabase.shared.setLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout) + + self.collectionView.reloadData() + self.collectionView.collectionViewLayout.invalidateLayout() + self.collectionView.setCollectionViewLayout(self.listLayout, animated: false) + + } else { + + // grid layout + headerMenu?.buttonSwitch.accessibilityLabel = NSLocalizedString("_list_view_", comment: "") + layoutForView?.layout = NCGlobal.shared.layoutGrid + NCManageDatabase.shared.setLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout) + + self.collectionView.reloadData() + self.collectionView.collectionViewLayout.invalidateLayout() + self.collectionView.setCollectionViewLayout(self.gridLayout, animated: false) + } + } + + func tapButtonOrder(_ sender: Any) { + + let sortMenu = NCSortMenu() + sortMenu.toggleMenu(viewController: self, account: activeAccount.account, key: layoutKey, sortButton: sender as? UIButton, serverUrl: serverUrl) + } + // MARK: - Push metadata func pushMetadata(_ metadata: tableMetadata) { @@ -233,6 +318,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent viewController.type = type viewController.overwrite = overwrite viewController.items = items + viewController.selectIndexPath = selectIndexPath + viewController.titleCurrentFolder = metadata.fileNameView viewController.serverUrl = serverUrlPush @@ -247,14 +334,24 @@ extension NCSelect: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return } - + + if isEditMode { + if let index = selectOcId.firstIndex(of: metadata.ocId) { + selectOcId.remove(at: index) + } else { + selectOcId.append(metadata.ocId) + } + collectionView.reloadItems(at: [indexPath]) + return + } + if metadata.directory { pushMetadata(metadata) } else { - delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadata, type: type, items: items, overwrite: overwrite, copy: false, move: false) + delegate?.dismissSelect(serverUrl: serverUrl, metadata: metadata, type: type, items: items, indexPath: selectIndexPath, overwrite: overwrite, copy: false, move: false) self.dismiss(animated: true, completion: nil) } } @@ -301,141 +398,216 @@ extension NCSelect: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return dataSource.numberOfItemsInSection(section) + let numberOfItems = dataSource.numberOfItemsInSection(section) + emptyDataSet?.numberOfItemsInSection(numberOfItems, section: section) + return numberOfItems } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell, - let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return UICollectionViewCell() } + guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { + if layoutForView?.layout == NCGlobal.shared.layoutList { + return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell + } else { + return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell + } + } var isShare = false var isMounted = false isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionShared) isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCGlobal.shared.permissionMounted) - cell.listCellDelegate = self + // LAYOUT LIST + + if layoutForView?.layout == NCGlobal.shared.layoutList { + + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell + cell.delegate = self + + cell.fileObjectId = metadata.ocId + cell.fileUser = metadata.ownerId + cell.labelTitle.text = metadata.fileNameView + cell.labelTitle.textColor = .label + + cell.imageSelect.image = nil + cell.imageStatus.image = nil + cell.imageLocal.image = nil + cell.imageFavorite.image = nil + cell.imageShared.image = nil + cell.imageMore.image = nil + + cell.imageItem.image = nil + cell.imageItem.backgroundColor = nil + + cell.progressView.progress = 0.0 + + if metadata.directory { + + if metadata.e2eEncrypted { + cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted + } else if isShare { + cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(3) ? + (cell.imageItem.image = NCBrandColor.cacheImages.folderPublic) : + (cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe) + } else if metadata.mountType == "group" { + cell.imageItem.image = NCBrandColor.cacheImages.folderGroup + } else if isMounted { + cell.imageItem.image = NCBrandColor.cacheImages.folderExternal + } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { + cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload + } else { + cell.imageItem.image = NCBrandColor.cacheImages.folder + } + cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata) - cell.fileObjectId = metadata.ocId - cell.fileUser = metadata.ownerId - cell.labelTitle.text = metadata.fileNameView - cell.labelTitle.textColor = .label + cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) - cell.imageSelect.image = nil - cell.imageStatus.image = nil - cell.imageLocal.image = nil - cell.imageFavorite.image = nil - cell.imageShared.image = nil - cell.imageMore.image = nil + } else { - cell.imageItem.image = nil - cell.imageItem.backgroundColor = nil + cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size) - cell.progressView.progress = 0.0 + // image local + if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) { + cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag + } else if CCUtility.fileProviderStorageExists(metadata) { + cell.imageLocal.image = NCBrandColor.cacheImages.local + } + } - if metadata.directory { + // image Favorite + if metadata.favorite { + cell.imageFavorite.image = NCBrandColor.cacheImages.favorite + } - if metadata.e2eEncrypted { - cell.imageItem.image = NCImageCache.images.folderEncrypted - } else if isShare { - cell.imageItem.image = NCImageCache.images.folderSharedWithMe + // Share image + if isShare { + cell.imageShared.image = NCBrandColor.cacheImages.shared } else if !metadata.shareType.isEmpty { metadata.shareType.contains(3) ? - (cell.imageItem.image = NCImageCache.images.folderPublic) : - (cell.imageItem.image = NCImageCache.images.folderSharedWithMe) - } else if metadata.mountType == "group" { - cell.imageItem.image = NCImageCache.images.folderGroup - } else if isMounted { - cell.imageItem.image = NCImageCache.images.folderExternal - } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.imageItem.image = NCImageCache.images.folderAutomaticUpload + (cell.imageShared.image = NCBrandColor.cacheImages.shareByLink) : + (cell.imageShared.image = NCBrandColor.cacheImages.shared) } else { - cell.imageItem.image = NCImageCache.images.folder + cell.imageShared.image = NCBrandColor.cacheImages.canShare } - cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata) - - cell.labelInfo.text = utility.dateDiff(metadata.date as Date) - } else { + cell.imageSelect.isHidden = true + cell.backgroundView = nil + cell.hideButtonMore(true) + cell.hideButtonShare(true) + cell.selectMode(false) - cell.labelInfo.text = utility.dateDiff(metadata.date as Date) + " · " + utilityFileSystem.transformedSize(metadata.size) + // Live Photo + if metadata.livePhoto { + cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto + } - // image local - if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil { - cell.imageLocal.image = NCImageCache.images.offlineFlag - } else if utilityFileSystem.fileProviderStorageExists(metadata) { - cell.imageLocal.image = NCImageCache.images.local + // Remove last separator + if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 { + cell.separator.isHidden = true + } else { + cell.separator.isHidden = false } - } - // image Favorite - if metadata.favorite { - cell.imageFavorite.image = NCImageCache.images.favorite + // Add TAGS + cell.setTags(tags: Array(metadata.tags)) + + return cell } - cell.imageSelect.isHidden = true - cell.backgroundView = nil - cell.hideButtonMore(true) - cell.hideButtonShare(true) - cell.selectMode(false) + // LAYOUT GRID - // Live Photo - if metadata.isLivePhoto { - cell.imageStatus.image = NCImageCache.images.livePhoto - } + if layoutForView?.layout == NCGlobal.shared.layoutGrid { - // Remove last separator - if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 { - cell.separator.isHidden = true - } else { - cell.separator.isHidden = false - } + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell + cell.delegate = self - // Add TAGS - cell.setTags(tags: Array(metadata.tags)) + cell.fileObjectId = metadata.ocId + cell.fileUser = metadata.ownerId + cell.labelTitle.text = metadata.fileNameView + cell.labelTitle.textColor = .label - return cell - } + cell.imageSelect.image = nil + cell.imageStatus.image = nil + cell.imageLocal.image = nil + cell.imageFavorite.image = nil - func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { + cell.imageItem.image = nil + cell.imageItem.backgroundColor = nil - if kind == UICollectionView.elementKindSectionHeader { + cell.progressView.progress = 0.0 - if dataSource.getMetadataSourceForAllSections().isEmpty { + if metadata.directory { - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderEmptyData", for: indexPath) as? NCSectionHeaderEmptyData else { return NCSectionHeaderEmptyData() } - if self.dataSourceTask?.state == .running { - header.emptyImage.image = UIImage(named: "networkInProgress")?.image(color: .gray, size: UIScreen.main.bounds.width) - header.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "") - header.emptyDescription.text = "" + if metadata.e2eEncrypted { + cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted + } else if isShare { + cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe + } else if !metadata.shareType.isEmpty { + metadata.shareType.contains(3) ? + (cell.imageItem.image = NCBrandColor.cacheImages.folderPublic) : + (cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe) + } else if metadata.mountType == "group" { + cell.imageItem.image = NCBrandColor.cacheImages.folderGroup + } else if isMounted { + cell.imageItem.image = NCBrandColor.cacheImages.folderExternal + } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { + cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload } else { - header.emptyImage.image = UIImage(named: "folder")?.image(color: NCBrandColor.shared.brandElement, size: UIScreen.main.bounds.width) - if includeImages { - header.emptyTitle.text = NSLocalizedString("_files_no_files_", comment: "") - } else { - header.emptyTitle.text = NSLocalizedString("_files_no_folders_", comment: "") - } - header.emptyDescription.text = "" + cell.imageItem.image = NCBrandColor.cacheImages.folder } - return header + cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata) } else { - guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as? NCSectionHeaderMenu else { return NCSectionHeaderMenu() } - let (_, heightHeaderRichWorkspace, _) = getHeaderHeight(section: indexPath.section) + // image Local + if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) { + cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag + } else if CCUtility.fileProviderStorageExists(metadata) { + cell.imageLocal.image = NCBrandColor.cacheImages.local + } + } + + // image Favorite + if metadata.favorite { + cell.imageFavorite.image = NCBrandColor.cacheImages.favorite + } - self.headerMenu = header + cell.imageSelect.isHidden = true + cell.backgroundView = nil + cell.hideButtonMore(true) - header.delegate = self - header.setRichWorkspaceHeight(heightHeaderRichWorkspace) - header.setRichWorkspaceText(richWorkspaceText) - header.setViewTransfer(isHidden: true) - return header + // Live Photo + if metadata.livePhoto { + cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto } + return cell + } + return collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell + } + + func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { + + if kind == UICollectionView.elementKindSectionHeader { + + guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as? NCSectionHeaderMenu else { return UICollectionReusableView() } + let (_, heightHeaderRichWorkspace, _) = getHeaderHeight(section: indexPath.section) + + self.headerMenu = header + + header.delegate = self +// header.setButtonsView(height: 0) + header.setRichWorkspaceHeight(heightHeaderRichWorkspace) + header.setRichWorkspaceText(richWorkspaceText) + header.setViewTransfer(isHidden: true) + return header + } else { - guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as? NCSectionFooter else { return NCSectionFooter() } + guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as? NCSectionFooter else { return UICollectionReusableView() } let sections = dataSource.numberOfSections() let section = indexPath.section @@ -462,27 +634,36 @@ extension NCSelect: UICollectionViewDelegateFlowLayout { if let richWorkspaceText = richWorkspaceText { let trimmed = richWorkspaceText.trimmingCharacters(in: .whitespaces) - if trimmed.count > 0 { + // swiftlint:disable empty_count + if trimmed.count > 0 && !isSearching { headerRichWorkspace = UIScreen.main.bounds.size.height / 6 } + // swiftlint:enable empty_count } - return (0, headerRichWorkspace, 0) + if isSearching || layoutForView?.layout == NCGlobal.shared.layoutGrid || dataSource.numberOfSections() > 1 { + if section == 0 { + return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection) + } else { + return (0, 0, NCGlobal.shared.heightSection) + } + } else { + return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0) + } } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { - var height: CGFloat = 0 - if dataSource.getMetadataSourceForAllSections().isEmpty { - height = NCGlobal.shared.getHeightHeaderEmptyData(view: view, portraitOffset: 0, landscapeOffset: -20) - } else { - let (heightHeaderCommands, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: section) - height = heightHeaderCommands + heightHeaderRichWorkspace + heightHeaderSection - } - return CGSize(width: collectionView.frame.width, height: height) + + let (heightHeaderCommands, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: section) + let heightHeader = heightHeaderCommands + heightHeaderRichWorkspace + heightHeaderSection + + return CGSize(width: collectionView.frame.width, height: heightHeader) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize { + let sections = dataSource.numberOfSections() + if section == sections - 1 { return CGSize(width: collectionView.frame.width, height: NCGlobal.shared.endHeightFooter) } else { @@ -502,6 +683,14 @@ extension NCSelect { @objc func loadDatasource(withLoadFolder: Bool) { var predicate: NSPredicate? + var groupByField = "name" + + layoutForView = NCManageDatabase.shared.getLayoutForView(account: activeAccount.account, key: layoutKey, serverUrl: serverUrl) + + // set GroupField for Grid + if layoutForView?.layout == NCGlobal.shared.layoutGrid { + groupByField = "classFile" + } if includeDirectoryE2EEncryption { @@ -525,11 +714,12 @@ extension NCSelect { let metadatas = NCManageDatabase.shared.getMetadatas(predicate: predicate!) self.dataSource = NCDataSource(metadatas: metadatas, account: activeAccount.account, - sort: "fileName", - ascending: true, - directoryOnTop: true, + sort: layoutForView?.sort, + ascending: layoutForView?.ascending, + directoryOnTop: layoutForView?.directoryOnTop, favoriteOnTop: true, - groupByField: "none") + filterLivePhoto: true, + groupByField: groupByField) if withLoadFolder { loadFolder() @@ -569,47 +759,55 @@ class NCSelectCommandView: UIView { @IBOutlet weak var overwriteSwitch: UISwitch? @IBOutlet weak var overwriteLabel: UILabel? @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint! + @IBOutlet weak var buttonsWidthConstraint: NSLayoutConstraint! var selectView: NCSelect? private let gradient: CAGradientLayer = CAGradientLayer() override func awakeFromNib() { - separatorHeightConstraint.constant = 0.5 + separatorHeightConstraint.constant = 1.0 separatorView.backgroundColor = .separator - overwriteSwitch?.onTintColor = NCBrandColor.shared.brand + overwriteSwitch?.onTintColor = NCBrandColor.shared.customer overwriteLabel?.text = NSLocalizedString("_overwrite_", comment: "") - selectButton?.layer.cornerRadius = 15 + selectButton?.layer.cornerRadius = 10 selectButton?.layer.masksToBounds = true selectButton?.setTitle(NSLocalizedString("_select_", comment: ""), for: .normal) - selectButton?.backgroundColor = NCBrandColor.shared.brand - selectButton?.setTitleColor(UIColor(white: 1, alpha: 0.3), for: .highlighted) - selectButton?.setTitleColor(NCBrandColor.shared.brandText, for: .normal) + selectButton?.setBackgroundColor(NCBrandColor.shared.customer, for: .normal) + selectButton?.setTitleColor(.white, for: .normal) - createFolderButton?.layer.cornerRadius = 15 + createFolderButton?.layer.cornerRadius = 10 createFolderButton?.layer.masksToBounds = true createFolderButton?.setTitle(NSLocalizedString("_create_folder_", comment: ""), for: .normal) - createFolderButton?.backgroundColor = NCBrandColor.shared.brand - createFolderButton?.setTitleColor(UIColor(white: 1, alpha: 0.3), for: .highlighted) - createFolderButton?.setTitleColor(NCBrandColor.shared.brandText, for: .normal) + createFolderButton?.backgroundColor = .clear + createFolderButton?.setTitleColor(UIColor.label, for: .normal) + createFolderButton?.setImage(UIImage(named: "addFolder")?.imageColor(UIColor.label), for: .normal) + createFolderButton?.layer.borderWidth = 1 + createFolderButton?.layer.borderColor = UIColor.label.cgColor - copyButton?.layer.cornerRadius = 15 + copyButton?.layer.cornerRadius = 10 copyButton?.layer.masksToBounds = true copyButton?.setTitle(NSLocalizedString("_copy_", comment: ""), for: .normal) - copyButton?.backgroundColor = NCBrandColor.shared.brand - copyButton?.setTitleColor(UIColor(white: 1, alpha: 0.3), for: .highlighted) - copyButton?.setTitleColor(NCBrandColor.shared.brandText, for: .normal) + copyButton?.backgroundColor = .clear + copyButton?.setTitleColor(UIColor.label, for: .normal) + copyButton?.layer.borderWidth = 1 + copyButton?.layer.borderColor = UIColor.label.cgColor - moveButton?.layer.cornerRadius = 15 + moveButton?.layer.cornerRadius = 10 moveButton?.layer.masksToBounds = true moveButton?.setTitle(NSLocalizedString("_move_", comment: ""), for: .normal) - moveButton?.backgroundColor = NCBrandColor.shared.brand - moveButton?.setTitleColor(UIColor(white: 1, alpha: 0.3), for: .highlighted) - moveButton?.setTitleColor(NCBrandColor.shared.brandText, for: .normal) + moveButton?.setBackgroundColor(NCBrandColor.shared.customer, for: .normal) + moveButton?.setTitleColor(.white, for: .normal) + buttonsWidthConstraint?.constant = UIScreen.main.bounds.width > 321 ? 150 : 132 } - + + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + createFolderButton?.layer.borderColor = UIColor.label.cgColor + } + @IBAction func createFolderButtonPressed(_ sender: UIButton) { selectView?.createFolderButtonPressed(sender) } @@ -668,7 +866,7 @@ struct SelectView: UIViewControllerRepresentable { self.parent = parent } - func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], overwrite: Bool, copy: Bool, move: Bool) { + func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String, items: [Any], indexPath: [IndexPath], overwrite: Bool, copy: Bool, move: Bool) { if let serverUrl = serverUrl { self.parent.serverUrl = serverUrl } diff --git a/iOSClient/Select/NCSelectCommandViewCopyMove.xib b/iOSClient/Select/NCSelectCommandViewCopyMove.xib index ddf3475d85..4941320594 100644 --- a/iOSClient/Select/NCSelectCommandViewCopyMove.xib +++ b/iOSClient/Select/NCSelectCommandViewCopyMove.xib @@ -1,9 +1,9 @@ - - + + - + @@ -11,115 +11,118 @@ - - + + - - + + - + - - + + - + - + - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - + + + + + + - - - - - - - + + + + + + + + From 4b8c442df5b2e77fe53d7439719881ff07523c11 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:49:26 +0530 Subject: [PATCH 2/4] NMC 2157 - Merging changes after Nextcloud 4.9.2 release --- iOSClient/Select/NCSelect.swift | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index ff5b600a67..f7b1625a79 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -445,52 +445,52 @@ extension NCSelect: UICollectionViewDataSource { if metadata.directory { if metadata.e2eEncrypted { - cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted + cell.imageItem.image = NCImageCache.images.folderEncrypted } else if isShare { - cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe + cell.imageItem.image = NCImageCache.images.folderSharedWithMe } else if !metadata.shareType.isEmpty { metadata.shareType.contains(3) ? - (cell.imageItem.image = NCBrandColor.cacheImages.folderPublic) : - (cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe) + (cell.imageItem.image = NCImageCache.images.folderPublic) : + (cell.imageItem.image = NCImageCache.images.folderSharedWithMe) } else if metadata.mountType == "group" { - cell.imageItem.image = NCBrandColor.cacheImages.folderGroup + cell.imageItem.image = NCImageCache.images.folderGroup } else if isMounted { - cell.imageItem.image = NCBrandColor.cacheImages.folderExternal + cell.imageItem.image = NCImageCache.images.folderExternal } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload + cell.imageItem.image = NCImageCache.images.folderAutomaticUpload } else { - cell.imageItem.image = NCBrandColor.cacheImages.folder + cell.imageItem.image = NCImageCache.images.folder } cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata) - cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + cell.labelInfo.text = utility.dateDiff(metadata.date as Date) } else { - cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size) + cell.labelInfo.text = utility.dateDiff(metadata.date as Date) + " · " + utilityFileSystem.transformedSize(metadata.size) // image local - if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) { - cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag - } else if CCUtility.fileProviderStorageExists(metadata) { - cell.imageLocal.image = NCBrandColor.cacheImages.local + if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil { + cell.imageLocal.image = NCImageCache.images.offlineFlag + } else if utilityFileSystem.fileProviderStorageExists(metadata) { + cell.imageLocal.image = NCImageCache.images.local } } // image Favorite if metadata.favorite { - cell.imageFavorite.image = NCBrandColor.cacheImages.favorite + cell.imageFavorite.image = NCImageCache.images.favorite } // Share image if isShare { - cell.imageShared.image = NCBrandColor.cacheImages.shared + cell.imageShared.image = NCImageCache.images.shared } else if !metadata.shareType.isEmpty { metadata.shareType.contains(3) ? - (cell.imageShared.image = NCBrandColor.cacheImages.shareByLink) : - (cell.imageShared.image = NCBrandColor.cacheImages.shared) + (cell.imageShared.image = NCImageCache.images.shareByLink) : + (cell.imageShared.image = NCImageCache.images.shared) } else { - cell.imageShared.image = NCBrandColor.cacheImages.canShare + cell.imageShared.image = NCImageCache.images.canShare } cell.imageSelect.isHidden = true @@ -501,7 +501,7 @@ extension NCSelect: UICollectionViewDataSource { // Live Photo if metadata.livePhoto { - cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto + cell.imageStatus.image = NCImageCache.images.livePhoto } // Remove last separator @@ -542,37 +542,37 @@ extension NCSelect: UICollectionViewDataSource { if metadata.directory { if metadata.e2eEncrypted { - cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted + cell.imageItem.image = NCImageCache.images.folderEncrypted } else if isShare { - cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe + cell.imageItem.image = NCImageCache.images.folderSharedWithMe } else if !metadata.shareType.isEmpty { metadata.shareType.contains(3) ? - (cell.imageItem.image = NCBrandColor.cacheImages.folderPublic) : - (cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe) + (cell.imageItem.image = NCImageCache.images.folderPublic) : + (cell.imageItem.image = NCImageCache.images.folderSharedWithMe) } else if metadata.mountType == "group" { - cell.imageItem.image = NCBrandColor.cacheImages.folderGroup + cell.imageItem.image = NCImageCache.images.folderGroup } else if isMounted { - cell.imageItem.image = NCBrandColor.cacheImages.folderExternal + cell.imageItem.image = NCImageCache.images.folderExternal } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory { - cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload + cell.imageItem.image = NCImageCache.images.folderAutomaticUpload } else { - cell.imageItem.image = NCBrandColor.cacheImages.folder + cell.imageItem.image = NCImageCache.images.folder } cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata) } else { // image Local - if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) { - cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag - } else if CCUtility.fileProviderStorageExists(metadata) { - cell.imageLocal.image = NCBrandColor.cacheImages.local + if NCManageDatabase.shared.getTableLocalFile(ocId: metadata.ocId) != nil { + cell.imageLocal.image = NCImageCache.images.offlineFlag + } else if utilityFileSystem.fileProviderStorageExists(metadata) { + cell.imageLocal.image = NCImageCache.images.local } } // image Favorite if metadata.favorite { - cell.imageFavorite.image = NCBrandColor.cacheImages.favorite + cell.imageFavorite.image = NCImageCache.images.favorite } cell.imageSelect.isHidden = true @@ -581,7 +581,7 @@ extension NCSelect: UICollectionViewDataSource { // Live Photo if metadata.livePhoto { - cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto + cell.imageStatus.image = NCImageCache.images.livePhoto } return cell From eb031c6a8242e67dd535339bdbdb7f4e59a75556 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:57:19 +0530 Subject: [PATCH 3/4] NMC 2157 - Merging conflict resolve after nextcloud 4.9.3 release --- iOSClient/Select/NCSelect.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index f7b1625a79..4aeae5ebf6 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -500,7 +500,7 @@ extension NCSelect: UICollectionViewDataSource { cell.selectMode(false) // Live Photo - if metadata.livePhoto { + if metadata.isLivePhoto { cell.imageStatus.image = NCImageCache.images.livePhoto } @@ -580,7 +580,7 @@ extension NCSelect: UICollectionViewDataSource { cell.hideButtonMore(true) // Live Photo - if metadata.livePhoto { + if metadata.isLivePhoto { cell.imageStatus.image = NCImageCache.images.livePhoto } @@ -718,7 +718,6 @@ extension NCSelect { ascending: layoutForView?.ascending, directoryOnTop: layoutForView?.directoryOnTop, favoriteOnTop: true, - filterLivePhoto: true, groupByField: groupByField) if withLoadFolder { From 28a81cb8c749122d05bab6341dfef9a06cc506e5 Mon Sep 17 00:00:00 2001 From: TSI-amrutwaghmare <96108296+TSI-amrutwaghmare@users.noreply.github.com> Date: Fri, 12 Apr 2024 16:07:35 +0530 Subject: [PATCH 4/4] NMC 2157 - size lable upated after nextcloud 5.2.2 release --- .../Main/Collection Common/Cell/NCListCell.swift | 2 +- iOSClient/Select/NCSelect.swift | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/iOSClient/Main/Collection Common/Cell/NCListCell.swift b/iOSClient/Main/Collection Common/Cell/NCListCell.swift index db8c9ef791..a000e58167 100755 --- a/iOSClient/Main/Collection Common/Cell/NCListCell.swift +++ b/iOSClient/Main/Collection Common/Cell/NCListCell.swift @@ -286,7 +286,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto func writeInfoDateSize(date: NSDate, size: Int64) { labelInfo.text = NCUtility().dateDiff(date as Date) - labelSubinfo.text = " · " + NCUtilityFileSystem().transformedSize(size) + labelSubinfo.text = "" } func setAccessibility(label: String, value: String) { diff --git a/iOSClient/Select/NCSelect.swift b/iOSClient/Select/NCSelect.swift index 4aeae5ebf6..0183261f9a 100644 --- a/iOSClient/Select/NCSelect.swift +++ b/iOSClient/Select/NCSelect.swift @@ -423,7 +423,7 @@ extension NCSelect: UICollectionViewDataSource { if layoutForView?.layout == NCGlobal.shared.layoutList { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell - cell.delegate = self + cell.listCellDelegate = self cell.fileObjectId = metadata.ocId cell.fileUser = metadata.ownerId @@ -464,6 +464,7 @@ extension NCSelect: UICollectionViewDataSource { cell.imageItem.image = cell.imageItem.image?.colorizeFolder(metadata: metadata) cell.labelInfo.text = utility.dateDiff(metadata.date as Date) + cell.labelSubinfo.text = " · " + utilityFileSystem.transformedSize(metadata.size) } else { @@ -522,7 +523,7 @@ extension NCSelect: UICollectionViewDataSource { if layoutForView?.layout == NCGlobal.shared.layoutGrid { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell - cell.delegate = self + cell.gridCellDelegate = self cell.fileObjectId = metadata.ocId cell.fileUser = metadata.ownerId @@ -537,7 +538,7 @@ extension NCSelect: UICollectionViewDataSource { cell.imageItem.image = nil cell.imageItem.backgroundColor = nil - cell.progressView.progress = 0.0 +// cell.progressView.progress = 0.0 if metadata.directory { @@ -597,9 +598,14 @@ extension NCSelect: UICollectionViewDataSource { let (_, heightHeaderRichWorkspace, _) = getHeaderHeight(section: indexPath.section) self.headerMenu = header + if layoutForView?.layout == NCGlobal.shared.layoutGrid { + header.setImageSwitchList() + header.setImageSwitchGrid() + header.buttonSwitch.accessibilityLabel = NSLocalizedString("_grid_view_", comment: "") + } header.delegate = self -// header.setButtonsView(height: 0) + header.setButtonsView(height: 0) header.setRichWorkspaceHeight(heightHeaderRichWorkspace) header.setRichWorkspaceText(richWorkspaceText) header.setViewTransfer(isHidden: true) @@ -655,7 +661,7 @@ extension NCSelect: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { let (heightHeaderCommands, heightHeaderRichWorkspace, heightHeaderSection) = getHeaderHeight(section: section) - let heightHeader = heightHeaderCommands + heightHeaderRichWorkspace + heightHeaderSection + let heightHeader = typeOfCommandView == .copyMove ? 0 : heightHeaderCommands + heightHeaderRichWorkspace + heightHeaderSection return CGSize(width: collectionView.frame.width, height: heightHeader) }