marinofaggiana 4 years ago
parent
commit
35c1572e2a

+ 1 - 1
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -1248,7 +1248,7 @@ extension NCCollectionViewCommon: UICollectionViewDelegate {
             
             
             if CCUtility.fileProviderStorageExists(metadataTouch?.ocId, fileNameView: metadataTouch?.fileNameView) {
             if CCUtility.fileProviderStorageExists(metadataTouch?.ocId, fileNameView: metadataTouch?.fileNameView) {
                 guard let metadataTouch = metadataTouch else { return }
                 guard let metadataTouch = metadataTouch else { return }
-                _ = NCViewer.init(viewController: self, metadata: metadataTouch)
+                NCViewer.shared.view(viewController: self, metadata: metadataTouch)
             } else {
             } else {
                 NCNetworking.shared.download(metadata: metadataTouch!, selector: selectorLoadFileView) { (_) in }
                 NCNetworking.shared.download(metadata: metadataTouch!, selector: selectorLoadFileView) { (_) in }
             }
             }

+ 2 - 2
iOSClient/Main/Create cloud/NCCreateFormUploadDocuments.swift

@@ -329,7 +329,7 @@ import NCCommunication
                         self.dismiss(animated: true, completion: {
                         self.dismiss(animated: true, completion: {
                             let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: fileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url ?? "", contentType: result.contentType, livePhoto: false)
                             let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: fileName, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url ?? "", contentType: result.contentType, livePhoto: false)
                             
                             
-                            _ = NCViewer.init(viewController: self.appDelegate.activeViewController, metadata: metadata)
+                            NCViewer.shared.view(viewController: self.appDelegate.activeViewController, metadata: metadata)
                         })
                         })
                     }
                     }
                     
                     
@@ -351,7 +351,7 @@ import NCCommunication
                     
                     
                         let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: (fileName as NSString).deletingPathExtension + "." + self.fileNameExtension, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url!, contentType: "", livePhoto: false)
                         let metadata = NCManageDatabase.sharedInstance.createMetadata(account: self.appDelegate.account, fileName: (fileName as NSString).deletingPathExtension + "." + self.fileNameExtension, ocId: CCUtility.createRandomString(12), serverUrl: self.serverUrl, urlBase: self.appDelegate.urlBase, url: url!, contentType: "", livePhoto: false)
                     
                     
-                        _ = NCViewer.init(viewController: self.appDelegate.activeViewController, metadata: metadata)
+                        NCViewer.shared.view(viewController: self.appDelegate.activeViewController, metadata: metadata) 
                    })
                    })
                    
                    
                     
                     

+ 1 - 1
iOSClient/Networking/NCNetworkingNotificationCenter.swift

@@ -77,7 +77,7 @@ import Foundation
                                 
                                 
                             } else {
                             } else {
                                 
                                 
-                                _ = NCViewer.init(viewController: self.appDelegate.activeViewController, metadata: metadata)
+                                NCViewer.shared.view(viewController: self.appDelegate.activeViewController, metadata: metadata) 
                             }
                             }
                         }
                         }
                         
                         

+ 18 - 3
iOSClient/Viewer/NCViewer.swift

@@ -24,12 +24,17 @@
 import Foundation
 import Foundation
 
 
 class NCViewer: NSObject {
 class NCViewer: NSObject {
+    @objc static let shared: NCViewer = {
+        let instance = NCViewer()
+        return instance
+    }()
     
     
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    private var viewerQuickLook: NCViewerQuickLook?
+    
+    func view(viewController: UIViewController, metadata: tableMetadata) {
 
 
-    init(viewController: UIViewController, metadata: tableMetadata) {
-        super.init()
-
+        // DOCUMENTS
         if metadata.typeFile == k_metadataTypeFile_document {
         if metadata.typeFile == k_metadataTypeFile_document {
                 
                 
             // PDF
             // PDF
@@ -44,7 +49,17 @@ class NCViewer: NSObject {
                 
                 
                 navigationController.pushViewController(viewController, animated: true)
                 navigationController.pushViewController(viewController, animated: true)
             }
             }
+            return
         }
         }
+        
+        // OTHER
+        
+        let fileNamePath = NSTemporaryDirectory() + metadata.fileNameView
+
+        CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath)
+
+        viewerQuickLook = NCViewerQuickLook.init()
+        viewerQuickLook?.quickLook(url: URL(fileURLWithPath: fileNamePath))
     }
     }
     
     
     private func canPush(viewController: UIViewController) -> Bool {
     private func canPush(viewController: UIViewController) -> Bool {