Эх сурвалжийг харах

Fix button more in Grid layout, improved layout

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

+ 15 - 4
iOSClient/Main/NCMainCommon.swift

@@ -184,7 +184,7 @@ class NCMainCommon: NSObject {
     
     //MARK: -
     
-    func collectionViewCellForItemAt(_ indexPath: IndexPath, collectionView: UICollectionView, typeLayout: String, metadata: tableMetadata, serverUrl: String, isEditMode: Bool, selectFileID: [String], hideButtonMore: Bool, source: UIViewController) -> UICollectionViewCell {
+    func collectionViewCellForItemAt(_ indexPath: IndexPath, collectionView: UICollectionView, typeLayout: String, metadata: tableMetadata, serverUrl: String, isEditMode: Bool, selectFileID: [String], autoUploadFileName: String, autoUploadDirectory: String, hideButtonMore: Bool, source: UIViewController) -> UICollectionViewCell {
         
         var image: UIImage?
         var imagePreview = false
@@ -223,7 +223,13 @@ class NCMainCommon: NSObject {
             }
             
             if metadata.directory {
-                cell.imageItem.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+                
+                if metadata.fileName == autoUploadFileName && serverUrl == autoUploadDirectory {
+                    cell.imageItem.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folderAutomaticUpload"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+                } else {
+                    cell.imageItem.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+                }
+                
                 cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
                 
                 let lockServerUrl = CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)!
@@ -283,7 +289,7 @@ class NCMainCommon: NSObject {
             
             // GRID
             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
-            cell.delegate = self as? NCGridCellDelegate
+            cell.delegate = source as? NCGridCellDelegate
             
             cell.fileID = metadata.fileID
             cell.indexPath = indexPath
@@ -298,7 +304,12 @@ class NCMainCommon: NSObject {
             }
             
             if metadata.directory {
-                image = UIImage.init(named: "folder")
+                
+                if metadata.fileName == autoUploadFileName && serverUrl == autoUploadDirectory {
+                    image = UIImage.init(named: "folderAutomaticUpload")
+                } else {
+                    image = UIImage.init(named: "folder")
+                }
                 cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*6, height: image!.size.height*6, scale: 3.0, color: NCBrandColor.sharedInstance.brandElement)
                 cell.imageItem.contentMode = .center
                 

+ 8 - 1
iOSClient/Offline/NCOffline.swift

@@ -44,6 +44,9 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
     private var datasourceGroupBy = ""
     private var datasourceDirectoryOnTop = false
     
+    private var autoUploadFileName = ""
+    private var autoUploadDirectory = ""
+    
     private var listLayout: NCListLayout!
     private var gridLayout: NCGridLayout!
     
@@ -106,6 +109,10 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
         
         (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop) = NCUtility.sharedInstance.getLayoutForView(key: k_layout_view_offline)
         
+        // get auto upload folder
+        autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
+        autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(appDelegate.activeUrl)
+        
         if typeLayout == k_layout_list {
             collectionView.collectionViewLayout = listLayout
         } else {
@@ -586,7 +593,7 @@ class NCOffline: UIViewController ,UICollectionViewDataSource, UICollectionViewD
             return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
         }
         
-        let cell = NCMainCommon.sharedInstance.collectionViewCellForItemAt(indexPath, collectionView: collectionView, typeLayout: typeLayout, metadata: metadata, serverUrl: serverUrl, isEditMode: isEditMode, selectFileID: selectFileID, hideButtonMore: false, source: self)
+        let cell = NCMainCommon.sharedInstance.collectionViewCellForItemAt(indexPath, collectionView: collectionView, typeLayout: typeLayout, metadata: metadata, serverUrl: serverUrl, isEditMode: isEditMode, selectFileID: selectFileID, autoUploadFileName: autoUploadFileName, autoUploadDirectory: autoUploadDirectory, hideButtonMore: false, source: self)
         
         return cell
     }

+ 8 - 1
iOSClient/Select/NCSelect.swift

@@ -70,6 +70,9 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
     private var datasourceGroupBy = ""
     private var datasourceDirectoryOnTop = false
     
+    private var autoUploadFileName = ""
+    private var autoUploadDirectory = ""
+    
     private var listLayout: NCListLayout!
     private var gridLayout: NCGridLayout!
     
@@ -149,6 +152,10 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
         
         (typeLayout, datasourceSorted, datasourceAscending, datasourceGroupBy, datasourceDirectoryOnTop) = NCUtility.sharedInstance.getLayoutForView(key: layoutViewSelect)
         
+        // get auto upload folder
+        autoUploadFileName = NCManageDatabase.sharedInstance.getAccountAutoUploadFileName()
+        autoUploadDirectory = NCManageDatabase.sharedInstance.getAccountAutoUploadDirectory(appDelegate.activeUrl)
+        
         if typeLayout == k_layout_list {
             collectionView.collectionViewLayout = listLayout
         } else {
@@ -643,7 +650,7 @@ class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDe
             return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
         }
         
-        let cell = NCMainCommon.sharedInstance.collectionViewCellForItemAt(indexPath, collectionView: collectionView, typeLayout: typeLayout, metadata: metadata, serverUrl: serverUrl, isEditMode: isEditMode, selectFileID: selectFileID, hideButtonMore: true, source: self)
+        let cell = NCMainCommon.sharedInstance.collectionViewCellForItemAt(indexPath, collectionView: collectionView, typeLayout: typeLayout, metadata: metadata, serverUrl: serverUrl, isEditMode: isEditMode, selectFileID: selectFileID, autoUploadFileName: autoUploadFileName, autoUploadDirectory: autoUploadDirectory ,hideButtonMore: true, source: self)
         
         return cell
     }