marinofaggiana 4 жил өмнө
parent
commit
248830d0fe

+ 51 - 1
iOSClient/Favorites/NCFavorite.swift

@@ -91,6 +91,7 @@ class NCFavorite: UIViewController, UIGestureRecognizerDelegate, NCListCellDeleg
         NotificationCenter.default.addObserver(self, selector: #selector(deleteFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_deleteFile), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSource), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(downloadedFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_downloadedFile), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(triggerProgressTask(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_progressTask), object:nil)
 
         changeTheming()
     }
@@ -134,7 +135,7 @@ class NCFavorite: UIViewController, UIGestureRecognizerDelegate, NCListCellDeleg
         }
     }
     
-    //MARK: - NotificationCenter
+    // MARK: - NotificationCenter
 
     @objc func deleteFile(_ notification: NSNotification) {
         if self.view?.window == nil { return }
@@ -164,6 +165,32 @@ class NCFavorite: UIViewController, UIGestureRecognizerDelegate, NCListCellDeleg
         }
     }
     
+    @objc func triggerProgressTask(_ notification: NSNotification) {
+        if self.view?.window == nil { return }
+        
+        if let userInfo = notification.userInfo as NSDictionary? {
+//            let status = userInfo["status"] as? Int ?? Int(k_metadataStatusNormal)
+//            let progress = userInfo["progress"] as? CGFloat ?? 0
+//            let totalBytes = userInfo["totalBytes"] as? Double ?? 0
+//            let totalBytesExpected = userInfo["totalBytesExpected"] as? Double ?? 0
+            
+            if let ocId = userInfo["ocId"] as? String, let progress = userInfo["progress"] as? Float {
+                if let index = dataSource?.getIndexMetadata(ocId: ocId) {
+                    if let cell = collectionView?.cellForItem(at: IndexPath(row: index, section: 0)) {
+                        if layout == k_layout_grid {
+                            if progress > 0 {
+                                (cell as! NCGridCell).progressView.isHidden = false
+                                (cell as! NCGridCell).progressView.progress = progress
+                            }
+                        } else {
+                            (cell as! NCListCell).separator.backgroundColor = NCBrandColor.sharedInstance.separator
+                        }
+                    }
+                }
+            }
+        }
+    }
+    
     @objc func changeTheming() {
         appDelegate.changeTheming(self, tableView: nil, collectionView: collectionView, form: false)
     }
@@ -438,10 +465,33 @@ extension NCFavorite: UICollectionViewDataSource {
         }
         
         if layout == k_layout_grid {
+            
             cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
+            
+            (cell as! NCGridCell).progressView.tintColor = NCBrandColor.sharedInstance.brandElement
+            (cell as! NCGridCell).progressView.trackTintColor = .clear
+            (cell as! NCGridCell).progressView.transform = CGAffineTransform(scaleX: 1, y: 1)
+            
+            if metadata.status == k_metadataStatusInDownload  ||  metadata.status == k_metadataStatusInUpload {
+                (cell as! NCGridCell).progressView.isHidden = false
+            } else {
+                (cell as! NCGridCell).progressView.isHidden = true
+            }
+            
         } else {
+            
             cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
+            
+            (cell as! NCListCell).progressView.tintColor = NCBrandColor.sharedInstance.brandElement
+            (cell as! NCListCell).progressView.trackTintColor = .clear
+            (cell as! NCListCell).progressView.transform = CGAffineTransform(scaleX: 1, y: 1)
             (cell as! NCListCell).separator.backgroundColor = NCBrandColor.sharedInstance.separator
+            
+            if metadata.status == k_metadataStatusInDownload  ||  metadata.status == k_metadataStatusInUpload {
+                (cell as! NCListCell).progressView.isHidden = false
+            } else {
+                (cell as! NCListCell).progressView.isHidden = true
+            }
         }
         
         let shares = NCManageDatabase.sharedInstance.getTableShares(account: metadata.account, serverUrl: metadata.serverUrl, fileName: metadata.fileName)

+ 2 - 0
iOSClient/Main/Cell/NCGridCell.swift

@@ -36,6 +36,8 @@ class NCGridCell: UICollectionViewCell, NCImageCellProtocol {
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var buttonMore: UIButton!
 
+    @IBOutlet weak var progressView: UIProgressView!
+
     var filePreviewImageView : UIImageView {
         get{
          return imageItem

+ 11 - 6
iOSClient/Main/Cell/NCGridCell.xib

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -67,6 +65,9 @@
                             <constraint firstAttribute="width" constant="15" id="xLe-lb-N1p"/>
                         </constraints>
                     </imageView>
+                    <progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JQo-Vc-Ejk">
+                        <rect key="frame" x="0.0" y="220" width="220" height="2"/>
+                    </progressView>
                 </subviews>
             </view>
             <constraints>
@@ -74,6 +75,7 @@
                 <constraint firstItem="AYs-f2-vve" firstAttribute="leading" secondItem="5Ci-V1-hf5" secondAttribute="trailing" constant="-20" id="3e3-0A-NSl"/>
                 <constraint firstItem="eU3-lY-fKr" firstAttribute="top" secondItem="5Ci-V1-hf5" secondAttribute="bottom" constant="10" id="4Yq-Nh-z1l"/>
                 <constraint firstItem="EJs-Ro-nbe" firstAttribute="top" secondItem="5Ci-V1-hf5" secondAttribute="bottom" constant="5" id="89Q-77-ulE"/>
+                <constraint firstItem="VXh-sQ-LeX" firstAttribute="trailing" secondItem="JQo-Vc-Ejk" secondAttribute="trailing" id="E03-Dk-iZ5"/>
                 <constraint firstItem="DHy-Up-3Bh" firstAttribute="top" secondItem="VXh-sQ-LeX" secondAttribute="top" constant="5" id="ESV-qE-tbO"/>
                 <constraint firstItem="5Ci-V1-hf5" firstAttribute="top" secondItem="VXh-sQ-LeX" secondAttribute="top" id="Ouj-ZD-UFm"/>
                 <constraint firstItem="VXh-sQ-LeX" firstAttribute="trailing" secondItem="EJs-Ro-nbe" secondAttribute="trailing" id="Pfe-J0-t9I"/>
@@ -87,6 +89,8 @@
                 <constraint firstItem="5Ci-V1-hf5" firstAttribute="leading" secondItem="VXh-sQ-LeX" secondAttribute="leading" id="qT3-WD-iTV"/>
                 <constraint firstItem="5Ci-V1-hf5" firstAttribute="top" secondItem="AYs-f2-vve" secondAttribute="bottom" constant="-20" id="rLL-6g-ypv"/>
                 <constraint firstItem="a0p-rj-jnV" firstAttribute="top" secondItem="5Ci-V1-hf5" secondAttribute="bottom" constant="-20" id="upV-Ov-WWd"/>
+                <constraint firstItem="JQo-Vc-Ejk" firstAttribute="leading" secondItem="VXh-sQ-LeX" secondAttribute="leading" id="wiV-1m-wt8"/>
+                <constraint firstItem="VXh-sQ-LeX" firstAttribute="bottom" secondItem="JQo-Vc-Ejk" secondAttribute="bottom" constant="43" id="zV9-iQ-Zm5"/>
             </constraints>
             <viewLayoutGuide key="safeArea" id="VXh-sQ-LeX"/>
             <size key="customSize" width="220" height="260"/>
@@ -98,11 +102,12 @@
                 <outlet property="imageSelect" destination="DHy-Up-3Bh" id="mo9-rP-P4I"/>
                 <outlet property="imageStatus" destination="a0p-rj-jnV" id="6Dg-tf-evd"/>
                 <outlet property="labelTitle" destination="eU3-lY-fKr" id="0P7-yM-Asb"/>
+                <outlet property="progressView" destination="JQo-Vc-Ejk" id="cdf-7W-tao"/>
             </connections>
             <point key="canvasLocation" x="88" y="141.67916041979012"/>
         </collectionViewCell>
     </objects>
     <resources>
-        <image name="more" width="50" height="50"/>
+        <image name="more" width="425" height="425"/>
     </resources>
 </document>

+ 2 - 0
iOSClient/Main/Cell/NCListCell.swift

@@ -44,6 +44,8 @@ class NCListCell: UICollectionViewCell, NCImageCellProtocol {
     @IBOutlet weak var imageMore: UIImageView!
     @IBOutlet weak var buttonMore: UIButton!
     
+    @IBOutlet weak var progressView: UIProgressView!
+    
     @IBOutlet weak var separator: UIView!
     
     var filePreviewImageView : UIImageView {

+ 10 - 5
iOSClient/Main/Cell/NCListCell.xib

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -109,9 +107,13 @@
                             <constraint firstAttribute="height" constant="1" id="G5S-67-boG"/>
                         </constraints>
                     </view>
+                    <progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="m2p-oJ-j15">
+                        <rect key="frame" x="95" y="51" width="420" height="2"/>
+                    </progressView>
                 </subviews>
             </view>
             <constraints>
+                <constraint firstItem="Gu8-oz-zWa" firstAttribute="trailing" secondItem="m2p-oJ-j15" secondAttribute="trailing" constant="85" id="2zI-li-v77"/>
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="trailing" secondItem="jc6-Vg-TaS" secondAttribute="trailing" constant="50" id="4YU-yn-33L"/>
                 <constraint firstItem="H4E-G2-C1H" firstAttribute="leading" secondItem="w2m-Vw-hpd" secondAttribute="trailing" constant="-10" id="6fN-Jc-WID"/>
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="bottom" secondItem="Egg-cb-EhZ" secondAttribute="bottom" id="81D-sw-EaX"/>
@@ -123,11 +125,13 @@
                 <constraint firstItem="UtT-L6-mgW" firstAttribute="leading" secondItem="w2m-Vw-hpd" secondAttribute="trailing" constant="10" id="PQ8-0b-fLa"/>
                 <constraint firstItem="AXX-71-9Q6" firstAttribute="leading" secondItem="w2m-Vw-hpd" secondAttribute="trailing" constant="10" id="Qvq-r5-AX9"/>
                 <constraint firstItem="AyA-hP-r6w" firstAttribute="leading" secondItem="Gu8-oz-zWa" secondAttribute="leading" constant="10" id="RYl-cO-cCN"/>
+                <constraint firstItem="Gu8-oz-zWa" firstAttribute="bottom" secondItem="m2p-oJ-j15" secondAttribute="bottom" constant="7" id="SYv-gc-ahx"/>
                 <constraint firstItem="C4K-Nv-phA" firstAttribute="leading" secondItem="w2m-Vw-hpd" secondAttribute="trailing" constant="-10" id="Sof-wy-toF"/>
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="trailing" secondItem="UtT-L6-mgW" secondAttribute="trailing" constant="85" id="Tq4-bB-YMV"/>
                 <constraint firstItem="H4E-G2-C1H" firstAttribute="top" secondItem="w2m-Vw-hpd" secondAttribute="bottom" constant="-10" id="UWI-r9-vcA"/>
                 <constraint firstItem="7Q9-Tv-9yo" firstAttribute="top" secondItem="w2m-Vw-hpd" secondAttribute="bottom" constant="-10" id="XbB-4a-WpA"/>
                 <constraint firstItem="yhy-xd-w5C" firstAttribute="centerY" secondItem="Gu8-oz-zWa" secondAttribute="centerY" id="ZO7-Ny-L3I"/>
+                <constraint firstItem="m2p-oJ-j15" firstAttribute="leading" secondItem="w2m-Vw-hpd" secondAttribute="trailing" constant="10" id="Zyr-qM-9qP"/>
                 <constraint firstItem="yhy-xd-w5C" firstAttribute="leading" secondItem="o4u-0K-Qpt" secondAttribute="trailing" id="b6M-di-61w"/>
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="bottom" secondItem="AXX-71-9Q6" secondAttribute="bottom" constant="14" id="d06-sn-I3Y"/>
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="trailing" secondItem="Egg-cb-EhZ" secondAttribute="trailing" id="k8f-bU-D6I"/>
@@ -153,6 +157,7 @@
                 <outlet property="imageStatus" destination="7Q9-Tv-9yo" id="Qug-Q7-rRZ"/>
                 <outlet property="labelInfo" destination="AXX-71-9Q6" id="krb-tZ-UQ7"/>
                 <outlet property="labelTitle" destination="UtT-L6-mgW" id="Xv6-zM-2v1"/>
+                <outlet property="progressView" destination="m2p-oJ-j15" id="yFv-KS-nEy"/>
                 <outlet property="separator" destination="Egg-cb-EhZ" id="uhq-Nc-z8K"/>
                 <outlet property="shared" destination="jc6-Vg-TaS" id="w28-mv-Bvr"/>
                 <outlet property="sharedLeftConstraint" destination="4YU-yn-33L" id="3sA-l2-yrB"/>

+ 1 - 2
iOSClient/Main/NCDataSource.swift

@@ -156,9 +156,8 @@ import Foundation
         createMetadatas(metadatasSource: metadatas)
     }
     
-    // MARK: -
     
-    private func getIndexMetadata(ocId: String) -> Int? {
+    func getIndexMetadata(ocId: String) -> Int? {
         
         var index: Int = 0