marinofaggiana 4 年之前
父节点
当前提交
16ae76a3a4

+ 9 - 3
iOSClient/Favorites/NCFavorite.swift

@@ -359,6 +359,10 @@ extension NCFavorite: UICollectionViewDataSource {
                 if groupBy == "none" {
                     header.labelSection.isHidden = true
                     header.labelSectionHeightConstraint.constant = 0
+                } else {
+                    header.labelSection.isHidden = false
+                    header.setTitleLabel(title: "")
+                    header.labelSectionHeightConstraint.constant = sectionHeaderHeight
                 }
                 
                 return header
@@ -367,7 +371,8 @@ extension NCFavorite: UICollectionViewDataSource {
                 
                 let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
                 
-                //footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                let info = dataSource?.getFilesInformation()
+                footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
                 
                 return footer
             }
@@ -378,7 +383,7 @@ extension NCFavorite: UICollectionViewDataSource {
                 
                 let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
                 
-                //header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
+                header.setTitleLabel(title: "")
                 
                 return header
                 
@@ -386,7 +391,8 @@ extension NCFavorite: UICollectionViewDataSource {
                 
                 let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
                 
-                //footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                let info = dataSource?.getFilesInformation()
+                footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
                 
                 return footer
             }

+ 12 - 3
iOSClient/Main/NCDataSource.swift

@@ -121,13 +121,22 @@ import Foundation
         return metadatas.count
     }
     
-    @objc func getSize() -> Double {
-        
+    func getFilesInformation() -> (directories: Int,  files: Int, size: Double) {
+
+        var directories: Int = 0
+        var files: Int = 0
         var size: Double = 0
+
         for metadata in metadatas {
+            if metadata.directory {
+                directories += 1
+            } else {
+                files += 1
+            }
             size = size + metadata.size
         }
-        return size
+        
+        return (directories, files, size)
     }
     
 }

+ 14 - 10
iOSClient/Main/Section/NCSectionHeaderFooter.swift

@@ -60,8 +60,9 @@ class NCSectionHeaderMenu: UICollectionReusableView {
         buttonOrderWidthConstraint.constant = size.width + 5
     }
     
-    func setTitleLabel(sectionDatasource: CCSectionDataSourceMetadata, section: Int) {
+    func setTitleLabel(title: String) {
         
+        /*
         var title = ""
         
         if sectionDatasource.sections.object(at: section) is String {
@@ -71,6 +72,7 @@ class NCSectionHeaderMenu: UICollectionReusableView {
             let titleDate = sectionDatasource.sections.object(at: section) as! Date
             title = CCUtility.getTitleSectionDate(titleDate)
         }
+        */
         
         if title.contains("download") {
             labelSection.text = NSLocalizedString("_title_section_download_", comment: "")
@@ -123,8 +125,9 @@ class NCSectionHeader: UICollectionReusableView {
         self.backgroundColor = NCBrandColor.sharedInstance.select
     }
     
-    func setTitleLabel(sectionDatasource: CCSectionDataSourceMetadata, section: Int) {
+    func setTitleLabel(title: String) {
         
+        /*
         var title = ""
         
         if sectionDatasource.sections.object(at: section) is String {
@@ -134,6 +137,7 @@ class NCSectionHeader: UICollectionReusableView {
             let titleDate = sectionDatasource.sections.object(at: section) as! Date
             title = CCUtility.getTitleSectionDate(titleDate)
         }
+        */
         
         if title.contains("download") {
             labelSection.text = NSLocalizedString("_title_section_download_", comment: "")
@@ -156,21 +160,21 @@ class NCSectionFooter: UICollectionReusableView {
         labelSection.textColor = NCBrandColor.sharedInstance.icon
     }
     
-    func setTitleLabel(sectionDatasource: CCSectionDataSourceMetadata) {
+    func setTitleLabel(directories: Int, files: Int, size: Double) {
         
         var foldersText = ""
         var filesText = ""
         
-        if sectionDatasource.directories > 1 {
-            foldersText = "\(sectionDatasource.directories) " + NSLocalizedString("_folders_", comment: "")
-        } else if sectionDatasource.directories == 1 {
+        if directories > 1 {
+            foldersText = "\(directories) " + NSLocalizedString("_folders_", comment: "")
+        } else if directories == 1 {
             foldersText = "1 " + NSLocalizedString("_folder_", comment: "")
         }
         
-        if sectionDatasource.files > 1 {
-            filesText = "\(sectionDatasource.files) " + NSLocalizedString("_files_", comment: "") + " " + CCUtility.transformedSize(sectionDatasource.totalSize)
-        } else if sectionDatasource.files == 1 {
-            filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(sectionDatasource.totalSize)
+        if files > 1 {
+            filesText = "\(files) " + NSLocalizedString("_files_", comment: "") + " " + CCUtility.transformedSize(size)
+        } else if files == 1 {
+            filesText = "1 " + NSLocalizedString("_file_", comment: "") + " " + CCUtility.transformedSize(size)
         }
         
         if foldersText == "" {

+ 6 - 5
iOSClient/Offline/NCOffline.swift

@@ -99,7 +99,8 @@ class NCOffline: UIViewController, UIGestureRecognizerDelegate, NCListCellDelega
         
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(deleteFile(_:)), name: NSNotification.Name(rawValue: k_notificationCenter_deleteFile), object: nil)
-        
+        NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSource), object: nil)
+
         changeTheming()
     }
     
@@ -436,7 +437,7 @@ extension NCOffline: UICollectionViewDataSource {
                     header.labelSectionHeightConstraint.constant = 0
                 } else {
                     header.labelSection.isHidden = false
-                    header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
+                    header.setTitleLabel(title: "")
                     header.labelSectionHeightConstraint.constant = sectionHeaderHeight
                 }
                 
@@ -446,7 +447,7 @@ extension NCOffline: UICollectionViewDataSource {
                 
                 let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
                 
-                footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                footer.setTitleLabel(directories: sectionDatasource.directories, files: sectionDatasource.files, size: sectionDatasource.totalSize)
                 
                 return footer
             }
@@ -457,7 +458,7 @@ extension NCOffline: UICollectionViewDataSource {
                 
                 let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
                 
-                header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
+                header.setTitleLabel(title: "")
                 
                 return header
                 
@@ -465,7 +466,7 @@ extension NCOffline: UICollectionViewDataSource {
                 
                 let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
                 
-                footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                footer.setTitleLabel(directories: sectionDatasource.directories, files: sectionDatasource.files, size: sectionDatasource.totalSize)
                 
                 return footer
             }

+ 10 - 5
iOSClient/Select/NCSelect.swift

@@ -148,7 +148,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
         buttonDone1.setTitleColor(.black, for: .normal)
                 
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
-        
+        NotificationCenter.default.addObserver(self, selector: #selector(reloadDataSource), name: NSNotification.Name(rawValue: k_notificationCenter_reloadDataSource), object: nil)
+
         changeTheming()
     }
     
@@ -416,7 +417,7 @@ extension NCSelect: UICollectionViewDataSource {
                     header.labelSectionHeightConstraint.constant = 0
                 } else {
                     header.labelSection.isHidden = false
-                    header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
+                    header.setTitleLabel(title: "")
                     header.labelSectionHeightConstraint.constant = sectionHeaderHeight
                 }
                 
@@ -426,7 +427,7 @@ extension NCSelect: UICollectionViewDataSource {
                 
                 let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
                 
-                footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                footer.setTitleLabel(directories: sectionDatasource.directories, files: sectionDatasource.files, size: sectionDatasource.totalSize)
                 
                 return footer
             }
@@ -437,7 +438,7 @@ extension NCSelect: UICollectionViewDataSource {
                 
                 let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
                 
-                header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
+                header.setTitleLabel(title: "")
                 
                 return header
                 
@@ -445,7 +446,7 @@ extension NCSelect: UICollectionViewDataSource {
                 
                 let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
                 
-                footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                footer.setTitleLabel(directories: sectionDatasource.directories, files: sectionDatasource.files, size: sectionDatasource.totalSize)
                 
                 return footer
             }
@@ -522,6 +523,10 @@ extension NCSelect: UICollectionViewDelegateFlowLayout {
 
 extension NCSelect {
 
+    @objc func reloadDataSource() {
+        loadDatasource(withLoadFolder: false)
+    }
+    
     @objc func loadDatasource(withLoadFolder: Bool) {
         
         var predicate: NSPredicate?