marinofaggiana 4 年之前
父節點
當前提交
60d53df563

+ 1 - 0
iOSClient/Favorites/NCFavorite.swift

@@ -41,6 +41,7 @@ class NCFavorite: NCCollectionViewCommon  {
     // MARK: - Collection View
     
     override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        super.collectionView(collectionView, didSelectItemAt: indexPath)
         
         guard let metadata = dataSource?.cellForItemAt(indexPath: indexPath) else { return }
         metadataPush = metadata

+ 23 - 9
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -167,6 +167,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             appDelegate.activeServerUrl = self.serverUrl
         }
         
+        setNavigationItem()
         reloadDataSource()
     }
         
@@ -184,6 +185,16 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
     
+    func setNavigationItem() {
+        if isEditMode {
+            self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "navigationMore"), style: .plain, target: self, action:#selector(tapSelectMenu(sender:)))
+            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, target: self, action: #selector(tapSelect(sender:)))
+        } else {
+            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_select_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(tapSelect(sender:)))
+            self.navigationItem.leftBarButtonItem = nil
+        }
+    }
+    
     // MARK: - Utility
     
     @objc func minCharTextFieldDidChange(sender: UITextField) {
@@ -516,6 +527,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     @objc func tapSelect(sender: Any) {
         
         isEditMode = !isEditMode
+        selectOcId.removeAll()
+        setNavigationItem()
         self.collectionView.reloadData()
     }
     
@@ -685,9 +698,18 @@ extension NCCollectionViewCommon: UIViewControllerPreviewingDelegate {
 }
 
 // MARK: - Collection View
+
 extension NCCollectionViewCommon: UICollectionViewDelegate {
 
     func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { }
+    
+    func collectionViewSelectAll() {
+        selectOcId.removeAll()
+        for metadata in metadatasSource {
+            selectOcId.append(metadata.ocId)
+        }
+        collectionView.reloadData()
+    }
 }
 
 extension NCCollectionViewCommon: UICollectionViewDataSource {
@@ -695,15 +717,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
     func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
         
         if kind == UICollectionView.elementKindSectionHeader {
-            
-            if isEditMode {
-                self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "navigationMore"), style: .plain, target: self, action:#selector(tapSelectMenu(sender:)))
-                self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: .plain, target: self, action: #selector(tapSelect(sender:)))
-            } else {
-                self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_select_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(tapSelect(sender:)))
-                self.navigationItem.leftBarButtonItem = nil
-            }
-            
+                        
             let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
             
             if collectionView.collectionViewLayout == gridLayout {

+ 1 - 0
iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -237,6 +237,7 @@ extension NCCollectionViewCommon {
                 title: NSLocalizedString("_select_all_", comment: ""),
                 icon: CCGraphics.changeThemingColorImage(UIImage(named: "selectFull"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
                 action: { menuAction in
+                    self.collectionViewSelectAll()
                 }
             )
         )