瀏覽代碼

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 年之前
父節點
當前提交
0c7c5027c7

+ 7 - 8
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1497,9 +1497,6 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
             if cell is NCListCell {
                 (cell as? NCListCell)?.delegate = self
-                (cell as? NCListCell)?.titleInfoTrailingDefault()
-                (cell as? NCListCell)?.hideButtonShare(false)
-                (cell as? NCListCell)?.hideButtonMore(false)
             }
 
             if cell is NCGridCell {
@@ -1518,6 +1515,9 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.fileUser = metadata.ownerId
             cell.fileProgressView?.isHidden = true
             cell.fileProgressView?.progress = 0.0
+            cell.hideButtonShare(false)
+            cell.hideButtonMore(false)
+            cell.titleInfoTrailingDefault()
 
             if isSearching {
                 cell.fileTitleLabel?.text = metadata.fileName
@@ -1526,9 +1526,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                     cell.fileInfoLabel?.text = NSLocalizedString("_in_", comment: "") + " " + NCUtilityFileSystem.shared.getPath(metadata: metadata, withFileName: false)
                 } else {
                     cell.fileInfoLabel?.text = metadata.subline
-                    if cell is NCListCell {
-                        (cell as? NCListCell)?.titleInfoTrailingFull()
-                    }
+                    cell.titleInfoTrailingFull()
                 }
                 if let literalSearch = self.literalSearch {
                     let longestWordRange = (metadata.fileName.lowercased() as NSString).range(of: literalSearch)
@@ -1618,6 +1616,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
                 cell.fileSharedImage?.image = NCBrandColor.cacheImages.shared
             }
 
+            // Button More
             if metadata.status == NCGlobal.shared.metadataStatusInDownload || metadata.status == NCGlobal.shared.metadataStatusDownloading || metadata.status == NCGlobal.shared.metadataStatusInUpload || metadata.status == NCGlobal.shared.metadataStatusUploading {
                 cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
             } else if metadata.lock == true {
@@ -1686,9 +1685,9 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
             // Separator
             if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 || isSearching {
-                if cell is NCListCell { (cell as? NCListCell)?.separator.isHidden = true }
+                cell.cellSeparatorView?.isHidden = true
             } else {
-                if cell is NCListCell { (cell as? NCListCell)?.separator.isHidden = false }
+                cell.cellSeparatorView?.isHidden = false
             }
 
             // Edit mode

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

@@ -101,6 +101,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
         get { return imageMore }
         set { imageMore = newValue }
     }
+    var cellSeparatorView: UIView? {
+        get { return separator }
+        set { separator = newValue }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 9 - 0
iOSClient/Main/NCCellProtocol.swift

@@ -38,7 +38,10 @@ protocol NCCellProtocol {
     var fileFavoriteImage: UIImageView? { get set }
     var fileSharedImage: UIImageView? { get set }
     var fileMoreImage: UIImageView? { get set }
+    var cellSeparatorView: UIView? { get set }
 
+    func titleInfoTrailingDefault()
+    func titleInfoTrailingFull()
     func writeInfoDateSize(date: NSDate, totalBytes: Int64)
     func setButtonMore(named: String, image: UIImage)
     func hideButtonShare(_ status: Bool)
@@ -96,7 +99,13 @@ extension NCCellProtocol {
         get { return nil }
         set {}
     }
+    var cellSeparatorView: UIView? {
+        get { return nil }
+        set {}
+    }
 
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
     func hideButtonShare(_ status: Bool) {}