Browse Source

improved animation

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 years ago
parent
commit
8a5a182896

+ 4 - 4
iOSClient/Data/NCDataSource.swift

@@ -26,10 +26,11 @@ import NCCommunication
 
 class NCDataSource: NSObject {
 
-    public var metadatas: [tableMetadata] = []
-    public var metadatasForSection: [NCMetadataForSection] = []
+    var metadatas: [tableMetadata] = []
+    var metadatasForSection: [NCMetadataForSection] = []
 
-    public var directory: tableDirectory?
+    var directory: tableDirectory?
+    var groupByField: String = ""
 
     private var sectionsValue: [String] = []
     private var providers: [NCCSearchProvider]?
@@ -42,7 +43,6 @@ class NCDataSource: NSObject {
     private var directoryOnTop: Bool = true
     private var favoriteOnTop: Bool = true
     private var filterLivePhoto: Bool = true
-    private var groupByField: String = ""
 
     override init() {
         super.init()

+ 7 - 3
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -811,8 +811,10 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             layoutForView?.layout = NCGlobal.shared.layoutList
             NCUtility.shared.setLayoutForView(key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout)
             self.groupByField = "name"
-            self.dataSource.changeGroupByField(self.groupByField)
-
+            if self.dataSource.groupByField != self.groupByField {
+                self.dataSource.changeGroupByField(self.groupByField)
+            }
+            
             self.collectionView.reloadData()
             self.collectionView.collectionViewLayout.invalidateLayout()
             self.collectionView.setCollectionViewLayout(self.listLayout, animated: true)
@@ -828,7 +830,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             } else {
                 self.groupByField = "classFile"
             }
-            self.dataSource.changeGroupByField(self.groupByField)
+            if self.dataSource.groupByField != self.groupByField {
+                self.dataSource.changeGroupByField(self.groupByField)
+            }
 
             self.collectionView.reloadData()
             self.collectionView.collectionViewLayout.invalidateLayout()