marinofaggiana 4 years ago
parent
commit
737369b4be

+ 4 - 4
iOSClient/Favorites/NCFavorite.swift

@@ -89,10 +89,10 @@ class NCFavorite: NCCollectionViewCommon  {
         
         if !isSearching {
        
-            if serverUrl == nil {
+            if serverUrl == "" {
                 metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND favorite == true", appDelegate.account))
             } else {
-                metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl!))
+                metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
             }
         }
         
@@ -113,7 +113,7 @@ class NCFavorite: NCCollectionViewCommon  {
         isReloadDataSourceNetworkInProgress = true
         collectionView?.reloadData()
         
-        if serverUrl == nil {
+        if serverUrl == "" {
             
             NCNetworking.shared.listingFavoritescompletion(selector: selectorListingFavorite) { (account, metadatas, errorCode, errorDescription) in
                 if errorCode == 0 {
@@ -134,7 +134,7 @@ class NCFavorite: NCCollectionViewCommon  {
             
         } else {
             
-            NCNetworking.shared.readFolder(serverUrl: serverUrl!, account: appDelegate.account) { (account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, errorCode, errorDescription) in
+            NCNetworking.shared.readFolder(serverUrl: serverUrl, account: appDelegate.account) { (account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, errorCode, errorDescription) in
                 if errorCode == 0 {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory && CCUtility.getFavoriteOffline() {

+ 3 - 5
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -30,7 +30,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     internal let refreshControl = UIRefreshControl()
     internal var searchController: UISearchController?
     
-    @objc var serverUrl: String?
+    @objc var serverUrl: String = ""
         
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
        
@@ -161,7 +161,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
             collectionView?.collectionViewLayout = gridLayout
         }
         
-        if serverUrl == nil {
+        if serverUrl == "" {
             appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         } else {
             appDelegate.activeServerUrl = self.serverUrl
@@ -573,9 +573,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         toggleMoreSelect(viewController: tabBarController, selectOcId: selectOcId)
     }
     
-    func tapMoreHeader(sender: Any) {
-
-    }
+    func tapMoreHeader(sender: Any) { }
     
     func tapMoreListItem(with objectId: String, namedButtonMore: String, sender: Any) {
         

+ 3 - 3
iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -80,7 +80,7 @@ extension NCCollectionViewCommon {
         )
 
         // Favorite
-        if (layoutKey == k_layout_view_favorite && serverUrl == nil) || (layoutKey != k_layout_view_favorite) {
+        if (layoutKey == k_layout_view_favorite && serverUrl == "") || (layoutKey != k_layout_view_favorite) {
             actions.append(
                 NCMenuAction(
                     title: metadata.favorite ? NSLocalizedString("_remove_favorites_", comment: "") : NSLocalizedString("_add_favorites_", comment: ""),
@@ -97,7 +97,7 @@ extension NCCollectionViewCommon {
         }
         
         // Offline
-        if !isFolderEncrypted && (layoutKey == k_layout_view_offline && serverUrl == nil || (layoutKey != k_layout_view_offline)) {
+        if !isFolderEncrypted && (layoutKey == k_layout_view_offline && serverUrl == "" || (layoutKey != k_layout_view_offline)) {
             actions.append(
                 NCMenuAction(
                     title: isOffline ? NSLocalizedString("_remove_available_offline_", comment: "") :  NSLocalizedString("_set_available_offline_", comment: ""),
@@ -182,7 +182,7 @@ extension NCCollectionViewCommon {
         )
         
 
-        if !isFolderEncrypted && serverUrl != nil {
+        if !isFolderEncrypted && serverUrl != "" {
             actions.append(
                 NCMenuAction(
                     title: NSLocalizedString("_move_or_copy_", comment: ""),

+ 0 - 1
iOSClient/Media/NCMedia.swift

@@ -257,7 +257,6 @@ class NCMedia: UIViewController, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate,
                         viewController.selectFile = false
                         viewController.titleButtonDone = NSLocalizedString("_select_", comment: "")
                         viewController.type = "mediaFolder"
-                        viewController.heightToolBarTop = 50
                         
                         navigationController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
                         self.present(navigationController, animated: true, completion: nil)

+ 4 - 4
iOSClient/Offline/NCOffline.swift

@@ -92,7 +92,7 @@ class NCOffline: NCCollectionViewCommon  {
 
         if !isSearching {
             
-            if serverUrl == nil {
+            if serverUrl == "" {
                
                 if let directories = NCManageDatabase.sharedInstance.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.account), sorted: "serverUrl", ascending: true) {
                     for directory: tableDirectory in directories {
@@ -109,7 +109,7 @@ class NCOffline: NCCollectionViewCommon  {
                 
             } else {
                
-                metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl!))
+                metadatasSource = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account, serverUrl))
             }
         }
         
@@ -126,12 +126,12 @@ class NCOffline: NCCollectionViewCommon  {
             return
         }
                     
-        if serverUrl != nil {
+        if serverUrl != "" {
            
             isReloadDataSourceNetworkInProgress = true
             collectionView?.reloadData()
             
-            NCNetworking.shared.readFolder(serverUrl: serverUrl!, account: appDelegate.account) { (account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, errorCode, errorDescription) in
+            NCNetworking.shared.readFolder(serverUrl: serverUrl, account: appDelegate.account) { (account, metadataFolder, metadatas, metadatasUpdate, metadatasLocalUpdate, errorCode, errorDescription) in
                 if errorCode == 0 {
                     for metadata in metadatas ?? [] {
                         if !metadata.directory {

+ 40 - 67
iOSClient/Select/NCSelect.swift

@@ -57,7 +57,6 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
     @objc var isButtonDone1Hide = true
     @objc var isOverwriteHide = true
     @objc var keyLayout = k_layout_view_move
-    @objc var heightToolBarTop: CGFloat = 100
     @objc var array: [Any] = []
     
     var titleCurrentFolder = NCBrandOptions.sharedInstance.brand
@@ -76,7 +75,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
     private var overwrite = false
     
     private var dataSource: NCDataSource?
-    
+    internal var richWorkspaceText: String?
+
     private var layout = ""
     private var groupBy = ""
     private var titleButton = ""
@@ -88,8 +88,8 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
     private var listLayout: NCListLayout!
     private var gridLayout: NCGridLayout!
         
-    private let headerMenuHeight: CGFloat = 50
-    private let sectionHeaderHeight: CGFloat = 20
+    private let headerHeight: CGFloat = 50
+    private var headerRichWorkspaceHeight: CGFloat = 0
     private let footerHeight: CGFloat = 50
     
     private var shares: [tableShare]?
@@ -99,29 +99,27 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
     override func viewDidLoad() {
         super.viewDidLoad()
         
+        self.navigationController?.navigationBar.prefersLargeTitles = true
+        
         // Cell
         collectionView.register(UINib.init(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
         collectionView.register(UINib.init(nibName: "NCGridCell", bundle: nil), forCellWithReuseIdentifier: "gridCell")
         
         // Header
         collectionView.register(UINib.init(nibName: "NCSectionHeaderMenu", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderMenu")
-        collectionView.register(UINib.init(nibName: "NCSectionHeader", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeader")
         
         // Footer
         collectionView.register(UINib.init(nibName: "NCSectionFooter", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "sectionFooter")
         
         collectionView.alwaysBounceVertical = true
-        collectionView.backgroundColor = NCBrandColor.sharedInstance.backgroundForm
         
         listLayout = NCListLayout()
         gridLayout = NCGridLayout()
         
         // Add Refresh Control
         collectionView.addSubview(refreshControl)
-        
-        // Configure Refresh Control
-        refreshControl.tintColor = NCBrandColor.sharedInstance.brandElement
-        refreshControl.backgroundColor = NCBrandColor.sharedInstance.backgroundView
+        refreshControl.tintColor = NCBrandColor.sharedInstance.brandText
+        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brandElement
         refreshControl.addTarget(self, action: #selector(loadDatasource), for: .valueChanged)
         
         // empty Data Source
@@ -160,8 +158,7 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
         
         self.navigationItem.title = titleCurrentFolder
         
-        toolBarTop.constant = -heightToolBarTop
-        
+        toolBarTop.constant = -100
         buttonDone.setTitle(titleButtonDone, for: .normal)
         buttonDone1.setTitle(titleButtonDone1, for: .normal)
         buttonDone1.isHidden = isButtonDone1Hide
@@ -379,7 +376,6 @@ extension NCSelect: UICollectionViewDelegate {
             visualController.isButtonDone1Hide = isButtonDone1Hide
             visualController.isOverwriteHide = isOverwriteHide
             visualController.overwrite = overwrite
-            visualController.heightToolBarTop = heightToolBarTop
             visualController.array = array
 
             visualController.titleCurrentFolder = metadataPush!.fileNameView
@@ -399,54 +395,34 @@ extension NCSelect: UICollectionViewDataSource {
 
     func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
         
-        if (indexPath.section == 0) {
+        if kind == UICollectionView.elementKindSectionHeader {
             
-            if kind == UICollectionView.elementKindSectionHeader {
-                
-                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
-                
-                if collectionView.collectionViewLayout == gridLayout {
-                    header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
-                } else {
-                    header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
-                }
-                
-                header.delegate = self
-                header.setStatusButton(count: dataSource?.metadatas.count ?? 0)
-                header.setTitleSorted(datasourceTitleButton: titleButton)
-                
-                return header
-                
+            let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
+            
+            if collectionView.collectionViewLayout == gridLayout {
+                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
             } else {
-                
-                let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
-                
-                let info = dataSource?.getFilesInformation()
-                footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
-                
-                return footer
+                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
             }
             
+            header.delegate = self
+            header.setStatusButton(count: dataSource?.metadatas.count ?? 0)
+            header.setTitleSorted(datasourceTitleButton: titleButton)
+            header.viewRichWorkspaceHeightConstraint.constant = headerRichWorkspaceHeight
+            header.setRichWorkspaceText(richWorkspaceText: richWorkspaceText)
+            
+            return header
+            
         } else {
             
-            if kind == UICollectionView.elementKindSectionHeader {
-                
-                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
-                
-                header.setTitleLabel(title: "")
-                
-                return header
-                
-            } else {
-                
-                let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
-                
-                let info = dataSource?.getFilesInformation()
-                footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
-                
-                return footer
-            }
+            let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
+            
+            let info = dataSource?.getFilesInformation()
+            footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
+            
+            return footer
         }
+            
     }
     
     func numberOfSections(in collectionView: UICollectionView) -> Int {
@@ -491,24 +467,18 @@ extension NCSelect: UICollectionViewDataSource {
 extension NCSelect: UICollectionViewDelegateFlowLayout {
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
-        if section == 0 {
-            if groupBy == "none" {
-                return CGSize(width: collectionView.frame.width, height: headerMenuHeight)
-            } else {
-                return CGSize(width: collectionView.frame.width, height: headerMenuHeight + sectionHeaderHeight)
-            }
+        
+        if richWorkspaceText?.count ?? 0 == 0 {
+            headerRichWorkspaceHeight = 0
         } else {
-            return CGSize(width: collectionView.frame.width, height: sectionHeaderHeight)
+            headerRichWorkspaceHeight = UIScreen.main.bounds.size.height / 4
         }
+        
+        return CGSize(width: collectionView.frame.width, height: headerHeight + headerRichWorkspaceHeight)
     }
     
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
-        let sections = 1
-        if (section == sections - 1) {
-            return CGSize(width: collectionView.frame.width, height: footerHeight)
-        } else {
-            return CGSize(width: collectionView.frame.width, height: 0)
-        }
+        return CGSize(width: collectionView.frame.width, height: footerHeight)
     }
 }
 
@@ -560,6 +530,9 @@ extension NCSelect {
             self.refreshControl.endRefreshing()
         }
         
+        let directory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", appDelegate.account,serverUrl))
+        richWorkspaceText = directory?.richWorkspace
+        
         collectionView.reloadData()
     }
     

+ 0 - 1
iOSClient/Settings/CCManageAutoUpload.m

@@ -510,7 +510,6 @@
      viewController.type = @"";
      viewController.titleButtonDone = NSLocalizedString(@"_select_", nil);
      viewController.keyLayout = k_layout_view_move;
-     viewController.heightToolBarTop = 50;
      
      [navigationController setModalPresentationStyle:UIModalPresentationFullScreen];
      [self presentViewController:navigationController animated:YES completion:^{