Marino Faggiana 6 жил өмнө
parent
commit
6884705197

+ 12 - 3
iOSClient/Trash/NCTrash.storyboard

@@ -18,9 +18,8 @@
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="Zaz-Cl-qpZ">
-                                <rect key="frame" x="16" y="45" width="343" height="602"/>
-                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                            <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="Zaz-Cl-qpZ">
+                                <rect key="frame" x="0.0" y="45" width="375" height="602"/>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="fF1-wd-0xN">
                                     <size key="itemSize" width="50" height="50"/>
@@ -29,9 +28,19 @@
                                     <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
                                 </collectionViewFlowLayout>
                                 <cells/>
+                                <connections>
+                                    <outlet property="dataSource" destination="EFX-fO-Oip" id="2On-qP-zuG"/>
+                                    <outlet property="delegate" destination="EFX-fO-Oip" id="s3n-CL-8X2"/>
+                                </connections>
                             </collectionView>
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <constraints>
+                            <constraint firstItem="Zaz-Cl-qpZ" firstAttribute="leading" secondItem="Meh-VD-wWh" secondAttribute="leading" id="1bp-sm-u0X"/>
+                            <constraint firstItem="Meh-VD-wWh" firstAttribute="trailing" secondItem="Zaz-Cl-qpZ" secondAttribute="trailing" id="aNd-UL-hmu"/>
+                            <constraint firstItem="Meh-VD-wWh" firstAttribute="bottom" secondItem="Zaz-Cl-qpZ" secondAttribute="bottom" constant="20" id="aNr-tf-2AH"/>
+                            <constraint firstItem="Zaz-Cl-qpZ" firstAttribute="top" secondItem="Meh-VD-wWh" secondAttribute="top" constant="25" id="tji-wt-R7s"/>
+                        </constraints>
                         <viewLayoutGuide key="safeArea" id="Meh-VD-wWh"/>
                     </view>
                     <connections>

+ 14 - 5
iOSClient/Trash/NCTrash.swift

@@ -16,10 +16,15 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     var path = ""
     var itemHeight: CGFloat = 60
-    
+    var datasource = [tableTrash]()
+
+    var gridLayout: ListLayout!
+
     override func viewDidLoad() {
         super.viewDidLoad()
         
+        collectionView.register(UINib.init(nibName: "NCTrashListCell", bundle: nil), forCellWithReuseIdentifier: "cell")
+        collectionView.collectionViewLayout = ListLayout(itemHeight: 60)
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -35,7 +40,9 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
         ocNetworking?.listingTrash(appDelegate.activeUrl, path:path, account: appDelegate.activeAccount, success: { (item) in
             
             NCManageDatabase.sharedInstance.deleteTrash(filePath: self.path)
-            _ = NCManageDatabase.sharedInstance.addTrashs(item as! [tableTrash])
+            self.datasource = NCManageDatabase.sharedInstance.addTrashs(item as! [tableTrash])!
+            
+            self.collectionView.reloadData()
             
         }, failure: { (message, errorCode) in
             
@@ -45,15 +52,17 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
     
     // MARK: collectionView methods
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return 2
+        return datasource.count
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! NCTrashListCell
         
-        //let image = imagesToDisplay[indexPath.item]
-        //cell.imageView.image = image
+        let tableTrash = datasource[indexPath.item]
         
+        cell.configure(with: nil, title: tableTrash.trashbinFileName, info: "")
+                
         return cell
     }
     

+ 7 - 6
iOSClient/Trash/NCTrashListCell.swift

@@ -15,12 +15,13 @@ class NCTrashListCell: UICollectionViewCell {
     @IBOutlet weak var labelTitle: UILabel!
     @IBOutlet weak var labelInfo: UILabel!
 
-    override func prepareForReuse() {
-        super.prepareForReuse()
-        
-        imageView.image = nil
-        labelTitle.text = ""
-        labelInfo.text = ""
+    override func awakeFromNib() {
+        super.awakeFromNib()
     }
     
+    public func configure(with image: UIImage?, title: String, info: String) {
+        imageView.image = image
+        labelTitle.text = title
+        labelInfo.text = info
+    }
 }