Browse Source

coding

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

+ 0 - 1
iOSClient/Data/NCDataSource.swift

@@ -403,7 +403,6 @@ class NCMetadataForSection: NSObject {
     public var metadataShare: [String: tableShare] = [:]
     public var metadataOffLine: [String] = []
 
-
     init(sectionValue: String, metadatas: [tableMetadata], shares: [tableShare], localFiles: [tableLocalFile], lastSearchResult: NCCSearchResult?, sort: String, ascending: Bool, directoryOnTop: Bool, favoriteOnTop: Bool, filterLivePhoto: Bool) {
 
         self.sectionValue = sectionValue

+ 19 - 9
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1073,8 +1073,22 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                 if  self.isSearching, errorCode == 0, let metadatas = metadatas {
                     self.metadatasSource = metadatas
                 }
+                self.dataSource = NCDataSource(
+                    metadatasSource: self.metadatasSource,
+                    account: self.appDelegate.account,
+                    sort: self.layoutForView?.sort,
+                    ascending: self.layoutForView?.ascending,
+                    directoryOnTop: self.layoutForView?.directoryOnTop,
+                    favoriteOnTop: true,
+                    filterLivePhoto: true,
+                    groupByField: self.groupByField,
+                    providers: self.providers,
+                    searchResults: self.searchResults)
                 self.isReloadDataSourceNetworkInProgress = false
-                self.reloadDataSource()
+                DispatchQueue.main.async {
+                    self.refreshControl.endRefreshing()
+                    self.collectionView.reloadData()
+                }
             }
         }
     }
@@ -1855,18 +1869,14 @@ extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
             }
         }
 
-        if section == 0 && dataSource.numberOfSections() > 1 {
-            return (getHeaderHeight(), headerRichWorkspace, NCGlobal.shared.heightSection)
-        } else if section == 0 && dataSource.numberOfSections() == 1 {
-            if collectionView.collectionViewLayout == gridLayout {
+        if isSearching || collectionView.collectionViewLayout == gridLayout || dataSource.numberOfSections() > 1 {
+            if section == 0 {
                 return (getHeaderHeight(), headerRichWorkspace, NCGlobal.shared.heightSection)
             } else {
-                return (getHeaderHeight(), headerRichWorkspace, 0)
+                return (0, 0, NCGlobal.shared.heightSection)
             }
-        } else if section > 0 && dataSource.numberOfSections() > 1 {
-            return (0, 0, NCGlobal.shared.heightSection)
         } else {
-            return (0, 0, 0)
+            return (getHeaderHeight(), headerRichWorkspace, 0)
         }
     }
 

+ 6 - 8
iOSClient/Select/NCSelect.swift

@@ -298,6 +298,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, UIAdaptivePresent
             layoutForView?.layout = NCGlobal.shared.layoutGrid
             NCUtility.shared.setLayoutForView(key: layoutKey, serverUrl: serverUrl, layout: layoutForView?.layout)
         }
+
+        self.reloadDataSource()
     }
 
     func tapButtonOrder(_ sender: Any) {
@@ -679,18 +681,14 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
             }
         }
 
-        if section == 0 && dataSource.numberOfSections() > 1 {
-            return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
-        } else if section == 0 && dataSource.numberOfSections() == 1 {
-            if collectionView.collectionViewLayout == gridLayout {
+        if isSearching || collectionView.collectionViewLayout == gridLayout || dataSource.numberOfSections() > 1 {
+            if section == 0 {
                 return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, NCGlobal.shared.heightSection)
             } else {
-                return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
+                return (0, 0, NCGlobal.shared.heightSection)
             }
-        } else if section > 0 && dataSource.numberOfSections() > 1 {
-            return (0, 0, NCGlobal.shared.heightSection)
         } else {
-            return (0, 0, 0)
+            return (NCGlobal.shared.heightButtonsView, headerRichWorkspace, 0)
         }
     }