Quellcode durchsuchen

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana vor 2 Jahren
Ursprung
Commit
c0ee787901

+ 2 - 0
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -120,6 +120,8 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
 
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func hideButtonShare(_ status: Bool) {}
+    func hideButtonMore(_ status: Bool) {}
 }
 }
 
 
 // MARK: - Collection View
 // MARK: - Collection View

+ 55 - 71
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1498,6 +1498,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             if cell is NCListCell {
             if cell is NCListCell {
                 (cell as? NCListCell)?.delegate = self
                 (cell as? NCListCell)?.delegate = self
                 (cell as? NCListCell)?.titleInfoTrailingDefault()
                 (cell as? NCListCell)?.titleInfoTrailingDefault()
+                (cell as? NCListCell)?.hideButtonShare(false)
+                (cell as? NCListCell)?.hideButtonMore(false)
             }
             }
 
 
             if cell is NCGridCell {
             if cell is NCGridCell {
@@ -1510,13 +1512,14 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.fileFavoriteImage?.image = nil
             cell.fileFavoriteImage?.image = nil
             cell.fileSharedImage?.image = nil
             cell.fileSharedImage?.image = nil
             cell.fileMoreImage?.image = nil
             cell.fileMoreImage?.image = nil
-
             cell.filePreviewImageView?.image = nil
             cell.filePreviewImageView?.image = nil
             cell.filePreviewImageView?.backgroundColor = nil
             cell.filePreviewImageView?.backgroundColor = nil
             cell.fileObjectId = metadata.ocId
             cell.fileObjectId = metadata.ocId
             cell.fileUser = metadata.ownerId
             cell.fileUser = metadata.ownerId
             cell.fileTitleLabel?.textColor = NCBrandColor.shared.label
             cell.fileTitleLabel?.textColor = NCBrandColor.shared.label
             cell.fileInfoLabel?.textColor = NCBrandColor.shared.systemGray
             cell.fileInfoLabel?.textColor = NCBrandColor.shared.systemGray
+            cell.fileProgressView?.isHidden = true
+            cell.fileProgressView?.progress = 0.0
 
 
             if isSearching {
             if isSearching {
                 cell.fileTitleLabel?.text = metadata.fileName
                 cell.fileTitleLabel?.text = metadata.fileName
@@ -1541,39 +1544,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.fileInfoLabel?.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
                 cell.fileInfoLabel?.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
             }
             }
 
 
-
-
-        }
-
-
-
-        return cell!
-
-
-
-
-/*
-
-
-        //
-        // LAYOUT LIST
-        //
-        if layoutForView?.layout == NCGlobal.shared.layoutList {
-
-
-            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.hideButtonShare(false)
-            cell.hideButtonMore(false)
-
             // Progress
             // Progress
             var progress: Float = 0.0
             var progress: Float = 0.0
             var totalBytes: Int64 = 0
             var totalBytes: Int64 = 0
@@ -1581,15 +1551,10 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 progress = progressType.progress
                 progress = progressType.progress
                 totalBytes = progressType.totalBytes
                 totalBytes = progressType.totalBytes
             }
             }
-
             if metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusUploading {
             if metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusUploading {
-                cell.progressView.isHidden = false
-                cell.progressView.progress = progress
-            } else {
-                cell.progressView.isHidden = true
-                cell.progressView.progress = 0.0
+                cell.fileProgressView?.isHidden = false
+                cell.fileProgressView?.progress = progress
             }
             }
-
             var a11yValues: [String] = []
             var a11yValues: [String] = []
             if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account {
             if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account {
                 a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName)
                 a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName)
@@ -1598,22 +1563,22 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             if metadata.directory {
             if metadata.directory {
 
 
                 if metadata.e2eEncrypted {
                 if metadata.e2eEncrypted {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folderEncrypted
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folderEncrypted
                 } else if isShare {
                 } else if isShare {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folderSharedWithMe
                 } else if tableShare != nil && tableShare?.shareType != 3 {
                 } else if tableShare != nil && tableShare?.shareType != 3 {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folderSharedWithMe
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folderSharedWithMe
                 } else if tableShare != nil && tableShare?.shareType == 3 {
                 } else if tableShare != nil && tableShare?.shareType == 3 {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folderPublic
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folderPublic
                 } else if metadata.mountType == "group" {
                 } else if metadata.mountType == "group" {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folderGroup
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folderGroup
                 } else if isMounted {
                 } else if isMounted {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folderExternal
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folderExternal
                 } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory {
                 } else if metadata.fileName == autoUploadFileName && metadata.serverUrl == autoUploadDirectory {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folderAutomaticUpload
-                    cell.labelTitle.text = (cell.labelTitle.text ?? "") + " - " + NSLocalizedString("_auto_upload_folder_", comment: "")
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folderAutomaticUpload
+                    cell.fileTitleLabel?.text = (cell.fileTitleLabel?.text ?? "") + " - " + NSLocalizedString("_auto_upload_folder_", comment: "")
                 } else {
                 } else {
-                    cell.imageItem.image = NCBrandColor.cacheImages.folder
+                    cell.filePreviewImageView?.image = NCBrandColor.cacheImages.folder
                 }
                 }
 
 
                 let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
                 let lockServerUrl = CCUtility.stringAppendServerUrl(metadata.serverUrl, addFileName: metadata.fileName)!
@@ -1621,7 +1586,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
 
                 // Local image: offline
                 // Local image: offline
                 if tableDirectory != nil && tableDirectory!.offline {
                 if tableDirectory != nil && tableDirectory!.offline {
-                    cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
+                    cell.fileLocalImage?.image = NCBrandColor.cacheImages.offlineFlag
                 }
                 }
 
 
             } else {
             } else {
@@ -1629,30 +1594,30 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 // image local
                 // image local
                 if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) {
                 if dataSource.metadatasForSection[indexPath.section].metadataOffLine.contains(metadata.ocId) {
                     a11yValues.append(NSLocalizedString("_offline_", comment: ""))
                     a11yValues.append(NSLocalizedString("_offline_", comment: ""))
-                    cell.imageLocal.image = NCBrandColor.cacheImages.offlineFlag
+                    cell.fileLocalImage?.image = NCBrandColor.cacheImages.offlineFlag
                 } else if CCUtility.fileProviderStorageExists(metadata) {
                 } else if CCUtility.fileProviderStorageExists(metadata) {
-                    cell.imageLocal.image = NCBrandColor.cacheImages.local
+                    cell.fileLocalImage?.image = NCBrandColor.cacheImages.local
                 }
                 }
             }
             }
 
 
             // image Favorite
             // image Favorite
             if metadata.favorite {
             if metadata.favorite {
-                cell.imageFavorite.image = NCBrandColor.cacheImages.favorite
+                cell.fileFavoriteImage?.image = NCBrandColor.cacheImages.favorite
                 a11yValues.append(NSLocalizedString("_favorite_", comment: ""))
                 a11yValues.append(NSLocalizedString("_favorite_", comment: ""))
             }
             }
 
 
             // Share image
             // Share image
             if isShare {
             if isShare {
-                cell.imageShared.image = NCBrandColor.cacheImages.shared
+                cell.fileSharedImage?.image = NCBrandColor.cacheImages.shared
             } else if tableShare != nil && tableShare?.shareType == 3 {
             } else if tableShare != nil && tableShare?.shareType == 3 {
-                cell.imageShared.image = NCBrandColor.cacheImages.shareByLink
+                cell.fileSharedImage?.image = NCBrandColor.cacheImages.shareByLink
             } else if tableShare != nil && tableShare?.shareType != 3 {
             } else if tableShare != nil && tableShare?.shareType != 3 {
-                cell.imageShared.image = NCBrandColor.cacheImages.shared
+                cell.fileSharedImage?.image = NCBrandColor.cacheImages.shared
             } else {
             } else {
-                cell.imageShared.image = NCBrandColor.cacheImages.canShare
+                cell.fileSharedImage?.image = NCBrandColor.cacheImages.canShare
             }
             }
             if appDelegate.account != metadata.account {
             if appDelegate.account != metadata.account {
-                cell.imageShared.image = NCBrandColor.cacheImages.shared
+                cell.fileSharedImage?.image = NCBrandColor.cacheImages.shared
             }
             }
 
 
             if metadata.status == NCGlobal.shared.metadataStatusInDownload || metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusInUpload || metadata.status == NCGlobal.shared.metadataStatusUploading {
             if metadata.status == NCGlobal.shared.metadataStatusInDownload || metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusInUpload || metadata.status == NCGlobal.shared.metadataStatusUploading {
@@ -1667,39 +1632,37 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             // Write status on Label Info
             // Write status on Label Info
             switch metadata.status {
             switch metadata.status {
             case NCGlobal.shared.metadataStatusWaitDownload:
             case NCGlobal.shared.metadataStatusWaitDownload:
-                cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_download_", comment: "")
+                cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_download_", comment: "")
                 break
                 break
             case NCGlobal.shared.metadataStatusInDownload:
             case NCGlobal.shared.metadataStatusInDownload:
-                cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_download_", comment: "")
+                cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_download_", comment: "")
                 break
                 break
             case NCGlobal.shared.metadataStatusDownloading:
             case NCGlobal.shared.metadataStatusDownloading:
-                cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - ↓ " + CCUtility.transformedSize(totalBytes)
+                cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↓ " + CCUtility.transformedSize(totalBytes)
                 break
                 break
             case NCGlobal.shared.metadataStatusWaitUpload:
             case NCGlobal.shared.metadataStatusWaitUpload:
-                cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_upload_", comment: "")
+                cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_wait_upload_", comment: "")
                 break
                 break
             case NCGlobal.shared.metadataStatusInUpload:
             case NCGlobal.shared.metadataStatusInUpload:
-                cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_upload_", comment: "")
+                cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - " + NSLocalizedString("_status_in_upload_", comment: "")
                 break
                 break
             case NCGlobal.shared.metadataStatusUploading:
             case NCGlobal.shared.metadataStatusUploading:
-                cell.labelInfo.text = CCUtility.transformedSize(metadata.size) + " - ↑ " + CCUtility.transformedSize(totalBytes)
+                cell.fileInfoLabel?.text = CCUtility.transformedSize(metadata.size) + " - ↑ " + CCUtility.transformedSize(totalBytes)
                 break
                 break
             case NCGlobal.shared.metadataStatusUploadError:
             case NCGlobal.shared.metadataStatusUploadError:
                 if metadata.sessionError != "" {
                 if metadata.sessionError != "" {
-                    cell.labelInfo.text = NSLocalizedString("_status_wait_upload_", comment: "") + " " + metadata.sessionError
+                    cell.fileInfoLabel?.text = NSLocalizedString("_status_wait_upload_", comment: "") + " " + metadata.sessionError
                 } else {
                 } else {
-                    cell.labelInfo.text = NSLocalizedString("_status_wait_upload_", comment: "")
+                    cell.fileInfoLabel?.text = NSLocalizedString("_status_wait_upload_", comment: "")
                 }
                 }
                 break
                 break
             default:
             default:
                 break
                 break
             }
             }
 
 
-            cell.accessibilityLabel = metadata.fileNameView + ", " + (cell.labelInfo.text ?? "")
-
             // Live Photo
             // Live Photo
             if metadata.livePhoto {
             if metadata.livePhoto {
-                cell.imageStatus.image = NCBrandColor.cacheImages.livePhoto
+                cell.fileStatusImage?.image = NCBrandColor.cacheImages.livePhoto
                 a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: ""))
                 a11yValues.append(NSLocalizedString("_upload_mov_livephoto_", comment: ""))
             }
             }
 
 
@@ -1710,7 +1673,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
 
             // URL
             // URL
             if metadata.classFile == NCCommunicationCommon.typeClassFile.url.rawValue {
             if metadata.classFile == NCCommunicationCommon.typeClassFile.url.rawValue {
-                cell.imageLocal.image = nil
+                cell.fileLocalImage?.image = nil
                 cell.hideButtonShare(true)
                 cell.hideButtonShare(true)
                 cell.hideButtonMore(true)
                 cell.hideButtonMore(true)
                 if let ownerId = NCUtility.shared.getAvatarFromIconUrl(metadata: metadata) {
                 if let ownerId = NCUtility.shared.getAvatarFromIconUrl(metadata: metadata) {
@@ -1723,6 +1686,27 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.hideButtonShare(true)
                 cell.hideButtonShare(true)
             }
             }
 
 
+            //cell.accessibilityLabel = metadata.fileNameView + ", " + (cell.labelInfo.text ?? "")
+
+        }
+
+
+
+        return cell!
+
+
+
+
+/*
+
+
+        //
+        // LAYOUT LIST
+        //
+        if layoutForView?.layout == NCGlobal.shared.layoutList {
+
+
+
             // Separator
             // Separator
             if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearching {
             if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearching {
                 cell.separator.isHidden = true
                 cell.separator.isHidden = true

+ 2 - 0
iOSClient/Main/Collection Common/NCGridCell.swift

@@ -171,6 +171,8 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
         buttonMore.isHidden = status
         buttonMore.isHidden = status
     }
     }
 
 
+    func hideButtonShare(_ status: Bool) {}
+
     func selectMode(_ status: Bool) {
     func selectMode(_ status: Bool) {
         if status {
         if status {
             imageSelect.isHidden = false
             imageSelect.isHidden = false

+ 3 - 0
iOSClient/Main/Collection Common/NCListCell.swift

@@ -132,6 +132,9 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
 
 
         separator.backgroundColor = NCBrandColor.shared.separator
         separator.backgroundColor = NCBrandColor.shared.separator
         separatorHeightConstraint.constant = 0.5
         separatorHeightConstraint.constant = 0.5
+
+        labelTitle.text = ""
+        labelInfo.text = ""
     }
     }
 
 
     override func prepareForReuse() {
     override func prepareForReuse() {

+ 2 - 0
iOSClient/Main/NCCellProtocol.swift

@@ -40,4 +40,6 @@ protocol NCCellProtocol {
 
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64)
     func writeInfoDateSize(date: NSDate, totalBytes: Int64)
     func setButtonMore(named: String, image: UIImage)
     func setButtonMore(named: String, image: UIImage)
+    func hideButtonShare(_ status: Bool)
+    func hideButtonMore(_ status: Bool)
 }
 }

+ 2 - 0
iOSClient/Media/Cell/NCGridMediaCell.swift

@@ -129,4 +129,6 @@ class NCGridMediaCell: UICollectionViewCell, NCCellProtocol {
 
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func hideButtonShare(_ status: Bool) {}
+    func hideButtonMore(_ status: Bool) {}
 }
 }

+ 2 - 0
iOSClient/Notification/NCNotification.swift

@@ -402,6 +402,8 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol {
 
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func hideButtonShare(_ status: Bool) {}
+    func hideButtonMore(_ status: Bool) {}
 }
 }
 
 
 protocol NCNotificationCellDelegate: AnyObject {
 protocol NCNotificationCellDelegate: AnyObject {

+ 2 - 0
iOSClient/Share/NCShareCommentsCell.swift

@@ -107,6 +107,8 @@ class NCShareCommentsCell: UITableViewCell, NCCellProtocol {
 
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func hideButtonShare(_ status: Bool) {}
+    func hideButtonMore(_ status: Bool) {}
 }
 }
 
 
 protocol NCShareCommentsCellDelegate: AnyObject {
 protocol NCShareCommentsCellDelegate: AnyObject {

+ 4 - 2
iOSClient/Share/NCShareUserCell.swift

@@ -160,8 +160,8 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol {
 
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
     func setButtonMore(named: String, image: UIImage) {}
-    func titleInfoTrailingDefault() {}
-    func titleInfoTrailingFull() {}
+    func hideButtonShare(_ status: Bool) {}
+    func hideButtonMore(_ status: Bool) {}
 }
 }
 
 
 protocol NCShareUserCellDelegate: AnyObject {
 protocol NCShareUserCellDelegate: AnyObject {
@@ -275,4 +275,6 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol {
 
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func hideButtonShare(_ status: Bool) {}
+    func hideButtonMore(_ status: Bool) {}
 }
 }

+ 6 - 0
iOSClient/Transfers/NCTransferCell.swift

@@ -121,6 +121,9 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP
 
 
         separator.backgroundColor = NCBrandColor.shared.separator
         separator.backgroundColor = NCBrandColor.shared.separator
         separatorHeightConstraint.constant = 0.5
         separatorHeightConstraint.constant = 0.5
+
+        labelTitle.text = ""
+        labelInfo.text = ""
     }
     }
 
 
     override func prepareForReuse() {
     override func prepareForReuse() {
@@ -158,6 +161,9 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {
         labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + CCUtility.transformedSize(totalBytes)
         labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + CCUtility.transformedSize(totalBytes)
     }
     }
+
+    func hideButtonShare(_ status: Bool) {}
+    func hideButtonMore(_ status: Bool) {}
 }
 }
 
 
 protocol NCTransferCellDelegate: AnyObject {
 protocol NCTransferCellDelegate: AnyObject {