marinofaggiana vor 4 Jahren
Ursprung
Commit
6d7bed7cd8

+ 0 - 61
iOSClient/Favorites/NCFavorite.swift

@@ -50,67 +50,6 @@ class NCFavorite: NCCollectionViewCommon  {
         super.viewWillAppear(animated)
     }
     
-    // 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
-        
-        if isEditMode {
-            if let index = selectOcId.firstIndex(of: metadata.ocId) {
-                selectOcId.remove(at: index)
-            } else {
-                selectOcId.append(metadata.ocId)
-            }
-            collectionView.reloadItems(at: [indexPath])
-            return
-        }
-        
-        if metadata.directory {
-            
-            guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadataPush!.serverUrl, addFileName: metadataPush!.fileName) else { return }
-            let ncFavorite:NCFavorite = UIStoryboard(name: "NCFavorite", bundle: nil).instantiateInitialViewController() as! NCFavorite
-            
-            ncFavorite.serverUrl = serverUrlPush
-            ncFavorite.titleCurrentFolder = metadataPush!.fileNameView
-            
-            self.navigationController?.pushViewController(ncFavorite, animated: true)
-            
-        } else {
-            
-            if metadataFolder?.e2eEncrypted ?? false && !CCUtility.isEnd(toEndEnabled: appDelegate.account) {
-                NCContentPresenter.shared.messageNotification("_info_", description: "_e2e_goto_settings_for_enable_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorE2EENotEnabled), forced: true)
-                return
-            }
-            
-            if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType) != nil {
-                if NCCommunication.shared.isNetworkReachable() {
-                    performSegue(withIdentifier: "segueDetail", sender: self)
-                } else {
-                    NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
-                }
-                return
-            }
-            
-            if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isRichDocument(metadata) {
-                if NCCommunication.shared.isNetworkReachable() {
-                    performSegue(withIdentifier: "segueDetail", sender: self)
-                } else {
-                    NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
-                }
-                return
-            }
-            
-            if CCUtility.fileProviderStorageExists(metadataPush?.ocId, fileNameView: metadataPush?.fileNameView) {
-                performSegue(withIdentifier: "segueDetail", sender: self)
-            } else {
-                NCNetworking.shared.download(metadata: metadataPush!, selector: selectorLoadFileView) { (_) in }
-            }
-        }
-    }
-    
     // MARK: - NC API & Algorithm
     
     override func reloadDataSource() {

+ 72 - 1
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -22,6 +22,7 @@
 //
 
 import Foundation
+import NCCommunication
 
 class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate  {
 
@@ -717,7 +718,77 @@ extension NCCollectionViewCommon: UIViewControllerPreviewingDelegate {
 
 extension NCCollectionViewCommon: UICollectionViewDelegate {
 
-    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { }
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        
+        guard let metadata = dataSource?.cellForItemAt(indexPath: indexPath) else { return }
+        metadataPush = metadata
+        
+        if isEditMode {
+            if let index = selectOcId.firstIndex(of: metadata.ocId) {
+                selectOcId.remove(at: index)
+            } else {
+                selectOcId.append(metadata.ocId)
+            }
+            collectionView.reloadItems(at: [indexPath])
+            return
+        }
+        
+        if metadata.directory {
+            
+            guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadataPush!.serverUrl, addFileName: metadataPush!.fileName) else { return }
+            
+            if layoutKey == k_layout_view_favorite {
+            
+                let ncFavorite:NCFavorite = UIStoryboard(name: "NCFavorite", bundle: nil).instantiateInitialViewController() as! NCFavorite
+            
+                ncFavorite.serverUrl = serverUrlPush
+                ncFavorite.titleCurrentFolder = metadataPush!.fileNameView
+            
+                self.navigationController?.pushViewController(ncFavorite, animated: true)
+            }
+            
+            if layoutKey == k_layout_view_offline {
+                
+                let ncOffline:NCOffline = UIStoryboard(name: "NCOffline", bundle: nil).instantiateInitialViewController() as! NCOffline
+                
+                ncOffline.serverUrl = serverUrlPush
+                ncOffline.titleCurrentFolder = metadataPush!.fileNameView
+                
+                self.navigationController?.pushViewController(ncOffline, animated: true)
+            }
+            
+        } else {
+            
+            if metadataFolder?.e2eEncrypted ?? false && !CCUtility.isEnd(toEndEnabled: appDelegate.account) {
+                NCContentPresenter.shared.messageNotification("_info_", description: "_e2e_goto_settings_for_enable_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorE2EENotEnabled), forced: true)
+                return
+            }
+            
+            if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isDirectEditing(account: metadata.account, contentType: metadata.contentType) != nil {
+                if NCCommunication.shared.isNetworkReachable() {
+                    performSegue(withIdentifier: "segueDetail", sender: self)
+                } else {
+                    NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
+                }
+                return
+            }
+            
+            if metadata.typeFile == k_metadataTypeFile_document && NCUtility.shared.isRichDocument(metadata) {
+                if NCCommunication.shared.isNetworkReachable() {
+                    performSegue(withIdentifier: "segueDetail", sender: self)
+                } else {
+                    NCContentPresenter.shared.messageNotification("_info_", description: "_go_online_", delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.info, errorCode: Int(k_CCErrorOffline), forced: true)
+                }
+                return
+            }
+            
+            if CCUtility.fileProviderStorageExists(metadataPush?.ocId, fileNameView: metadataPush?.fileNameView) {
+                performSegue(withIdentifier: "segueDetail", sender: self)
+            } else {
+                NCNetworking.shared.download(metadata: metadataPush!, selector: selectorLoadFileView) { (_) in }
+            }
+        }
+    }
     
     func collectionViewSelectAll() {
         selectOcId.removeAll()

+ 0 - 42
iOSClient/Offline/NCOffline.swift

@@ -49,48 +49,6 @@ class NCOffline: NCCollectionViewCommon  {
         super.viewWillAppear(animated)
     }
     
-    // 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
-        
-        if isEditMode {
-            if let index = selectOcId.firstIndex(of: metadata.ocId) {
-                selectOcId.remove(at: index)
-            } else {
-                selectOcId.append(metadata.ocId)
-            }
-            collectionView.reloadItems(at: [indexPath])
-            return
-        }
-        
-        if metadata.directory {
-            
-            guard let serverUrlPush = CCUtility.stringAppendServerUrl(metadataPush!.serverUrl, addFileName: metadataPush!.fileName) else { return }
-            let ncOffline:NCOffline = UIStoryboard(name: "NCOffline", bundle: nil).instantiateInitialViewController() as! NCOffline
-            
-            ncOffline.serverUrl = serverUrlPush
-            ncOffline.titleCurrentFolder = metadataPush!.fileNameView
-            
-            self.navigationController?.pushViewController(ncOffline, animated: true)
-            
-        } else {
-            
-            if CCUtility.fileProviderStorageExists(metadataPush?.ocId, fileNameView: metadataPush?.fileNameView) {
-                performSegue(withIdentifier: "segueDetail", sender: self)
-            } else {
-                NCNetworking.shared.download(metadata: metadataPush!, selector: "") { (errorCode) in
-                    if errorCode == 0 {
-                        self.performSegue(withIdentifier: "segueDetail", sender: self)
-                    }
-                }
-            }
-        }
-    }
-    
     // MARK: - NC API & Algorithm
 
     override func reloadDataSource() {

+ 1 - 1
iOSClient/Transfers/NCTransfers.swift

@@ -198,7 +198,7 @@ class NCTransfers: NCCollectionViewCommon  {
     // MARK: - Collection View
     
     override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        super.collectionView(collectionView, didSelectItemAt: indexPath)
+        // nothing
     }
     
     override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {