marinofaggiana 4 years ago
parent
commit
6c4a6472f7

+ 4 - 4
iOSClient/Favorites/NCFavorite.swift

@@ -88,10 +88,10 @@ class NCFavorite: NCCollectionViewCommon  {
         
         if !isSearching {
        
-            if serverUrl == "" {
+            if serverUrl == nil {
                 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!))
             }
         }
         
@@ -112,7 +112,7 @@ class NCFavorite: NCCollectionViewCommon  {
         isReloadDataSourceNetworkInProgress = true
         collectionView?.reloadData()
         
-        if serverUrl == "" {
+        if serverUrl == nil {
             
             NCNetworking.shared.listingFavoritescompletion(selector: selectorListingFavorite) { (account, metadatas, errorCode, errorDescription) in
                 if errorCode == 0 {
@@ -133,7 +133,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() {

+ 15 - 2
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 = ""
+    @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 == "" {
+        if serverUrl == nil {
             appDelegate.activeServerUrl = NCUtility.shared.getHomeServer(urlBase: appDelegate.urlBase, account: appDelegate.account)
         } else {
             appDelegate.activeServerUrl = self.serverUrl
@@ -575,6 +575,19 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
     
+    func tapRichWorkspace(sender: Any) {
+        
+        if let navigationController = UIStoryboard(name: "NCViewerRichWorkspace", bundle: nil).instantiateInitialViewController() as? UINavigationController {
+            if let viewerRichWorkspace = navigationController.topViewController as? NCViewerRichWorkspace {
+                viewerRichWorkspace.richWorkspaceText = richWorkspaceText ?? ""
+                viewerRichWorkspace.serverUrl = appDelegate.activeServerUrl
+                
+                navigationController.modalPresentationStyle = .fullScreen
+                self.present(navigationController, animated: true, completion: nil)
+            }
+        }
+    }
+    
     // MARK: SEGUE
     
     @objc func segue(metadata: tableMetadata) {

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

@@ -24,7 +24,7 @@
 import Foundation
 import MarkdownKit
 
-class NCSectionHeaderMenu: UICollectionReusableView {
+class NCSectionHeaderMenu: UICollectionReusableView, UIGestureRecognizerDelegate {
     
     @IBOutlet weak var buttonMore: UIButton!
     @IBOutlet weak var buttonSwitch: UIButton!
@@ -60,6 +60,10 @@ class NCSectionHeaderMenu: UICollectionReusableView {
         gradient.endPoint = CGPoint(x: 0, y: 1)
         viewRichWorkspace.layer.addSublayer(gradient)
         
+        let tap = UITapGestureRecognizer(target: self, action: #selector(touchUpInsideViewRichWorkspace(_:)))
+        tap.delegate = self
+        viewRichWorkspace?.addGestureRecognizer(tap)
+        
         NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
         changeTheming()
     }
@@ -123,12 +127,17 @@ class NCSectionHeaderMenu: UICollectionReusableView {
     @IBAction func touchUpInsideOrder(_ sender: Any) {
         delegate?.tapOrderHeader(sender: sender)
     }
+    
+    @objc func touchUpInsideViewRichWorkspace(_ sender: Any) {
+        delegate?.tapRichWorkspace(sender: sender)
+    }
 }
 
 protocol NCSectionHeaderMenuDelegate {
     func tapSwitchHeader(sender: Any)
     func tapMoreHeader(sender: Any)
     func tapOrderHeader(sender: Any)
+    func tapRichWorkspace(sender: Any)
 }
 
 class NCSectionHeader: UICollectionReusableView {

+ 4 - 4
iOSClient/Offline/NCOffline.swift

@@ -92,7 +92,7 @@ class NCOffline: NCCollectionViewCommon  {
 
         if !isSearching {
             
-            if serverUrl == "" {
+            if serverUrl == nil {
                
                 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 != "" {
+        if serverUrl != nil {
            
             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 {

+ 3 - 0
iOSClient/Select/NCSelect.swift

@@ -336,6 +336,9 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
     
     func tapShareListItem(with objectId: String, sender: Any) {
     }
+    
+    func tapRichWorkspace(sender: Any) {
+    }
 }
 
 // MARK: - Collection View