Browse Source

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
f54c3096d0

+ 6 - 0
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -87,6 +87,12 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
         }
         set { }
     }
+    var progress: UIProgressView? {
+        get {
+            return nil
+        }
+        set { }
+    }
     
     @objc func tapAvatarImage() {
         guard let fileUser = fileUser else { return }

+ 20 - 2
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -594,9 +594,26 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         let status = userInfo["status"] as? Int ?? NCGlobal.shared.metadataStatusNormal
 
         if let cell = collectionView?.cellForItem(at: indexPath) {
-            if let cell = cell as? NCCellProtocol {
-                print (cell.title)
+            if var cell = cell as? NCCellProtocol {
+                if progressNumber.floatValue == 1 {
+                    cell.progress?.isHidden = true
+                    cell.progress?.progress = .zero
+                    if let metadata = NCManageDatabase.shared.getMetadataFromOcId(ocId) {
+                        cell.info = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
+                    } else {
+                        cell.info = ""
+                    }
+                } else {
+                    cell.progress?.isHidden = false
+                    cell.progress?.progress = progressNumber.floatValue
+                    if status == NCGlobal.shared.metadataStatusInDownload {
+                        cell.info = CCUtility.transformedSize(totalBytesExpected) + " - ↓ " + CCUtility.transformedSize(totalBytes)
+                    } else if status == NCGlobal.shared.metadataStatusInUpload {
+                        cell.info = CCUtility.transformedSize(totalBytesExpected) + " - ↑ " + CCUtility.transformedSize(totalBytes)
+                    }
+                }
             }
+            /*
             if cell is NCListCell {
                 let cell = cell as! NCListCell
                 if progressNumber.floatValue == 1 {
@@ -630,6 +647,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                     cell.setButtonMore(named: NCGlobal.shared.buttonMoreStop, image: NCBrandColor.cacheImages.buttonStop)
                 }
             }
+            */
         }
     }
 

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

@@ -84,6 +84,14 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
             labelInfo.text = newValue ?? ""
         }
     }
+    var progress: UIProgressView? {
+        get {
+            return progressView
+        }
+        set {
+            progressView = newValue
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -189,6 +197,10 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
             imageVisualEffect.isHidden = true
         }
     }
+
+    func writeInfoDateSize(date: NSDate, totalBytes: Int64) {
+
+    }
 }
 
 protocol NCGridCellDelegate: AnyObject {

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

@@ -92,6 +92,14 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
             labelInfo.text = newValue ?? ""
         }
     }
+    var progress: UIProgressView? {
+        get {
+            return progressView
+        }
+        set {
+            progressView = newValue
+        }
+    }
 
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -231,6 +239,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
             separator.isHidden = false
         }
     }
+
+    func writeInfoDateSize(date: NSDate, totalBytes: Int64) {
+        
+    }
 }
 
 protocol NCListCellDelegate: AnyObject {

+ 3 - 0
iOSClient/Main/NCCellProtocol.swift

@@ -30,4 +30,7 @@ protocol NCCellProtocol {
     var fileUser: String? { get }
     var title: String? { get set }
     var info: String? { get set }
+    var progress: UIProgressView? { get set }
+
+    func writeInfoDateSize(date: NSDate, totalBytes: Int64)
 }

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

@@ -73,6 +73,12 @@ class NCGridMediaCell: UICollectionViewCell, NCCellProtocol {
         }
         set { }
     }
+    var progress: UIProgressView? {
+        get {
+            nil
+        }
+        set { }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 6 - 0
iOSClient/Notification/NCNotification.swift

@@ -358,6 +358,12 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol {
         }
         set { }
     }
+    var progress: UIProgressView? {
+        get {
+            return nil
+        }
+        set { }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()

+ 7 - 1
iOSClient/Share/NCShareCommentsCell.swift

@@ -61,7 +61,13 @@ class NCShareCommentsCell: UITableViewCell, NCCellProtocol {
         }
         set { }
     }
-
+    var progress: UIProgressView? {
+        get {
+            return nil
+        }
+        set { }
+    }
+    
     override func awakeFromNib() {
         super.awakeFromNib()
 

+ 12 - 0
iOSClient/Share/NCShareUserCell.swift

@@ -59,6 +59,12 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol {
             status.text = newValue ?? ""
         }
     }
+    var progress: UIProgressView? {
+        get {
+            return nil
+        }
+        set { }
+    }
     
     func setupCellUI(userId: String) {
         guard let tableShare = tableShare else {
@@ -170,6 +176,12 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol {
         }
         set { }
     }
+    var progress: UIProgressView? {
+        get {
+            return nil
+        }
+        set { }
+    }
     
     func setupCell(sharee: NCCommunicationSharee, baseUrl: NCUserBaseUrl) {
         imageItem.image = NCShareCommon.shared.getImageShareType(shareType: sharee.shareType)

+ 8 - 0
iOSClient/Transfers/NCTransferCell.swift

@@ -85,6 +85,14 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP
             labelInfo.text = newValue ?? ""
         }
     }
+    var progress: UIProgressView? {
+        get {
+            return progressView
+        }
+        set {
+            progressView = newValue
+        }
+    }
     
     override func awakeFromNib() {
         super.awakeFromNib()