Browse Source

fix

Signed-off-by: Marino Faggiana <96728420+MarinoFaggianaAstraIridium@users.noreply.github.com>
Marino Faggiana 2 years ago
parent
commit
fca8c267ee

+ 1 - 2
iOSClient/Main/NCActionCenter.swift

@@ -71,6 +71,7 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
         case NCGlobal.shared.selectorLoadFileQuickLook:
             let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView)!
             let fileNameTemp = NSTemporaryDirectory() + metadata.fileNameView
+            let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNameTemp), isEditingEnabled: true, metadata: metadata)
             if let image = UIImage(contentsOfFile: fileNamePath) {
                 if let data = image.jpegData(compressionQuality: 1) {
                     do {
@@ -79,13 +80,11 @@ class NCActionCenter: NSObject, UIDocumentInteractionControllerDelegate, NCSelec
                         return
                     }
                 }
-                let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNameTemp), isEditingEnabled: true, isCropEnabled: true, metadata: metadata)
                 let navigationController = UINavigationController(rootViewController: viewerQuickLook)
                 navigationController.modalPresentationStyle = .fullScreen
                 appDelegate.window?.rootViewController?.present(navigationController, animated: true)
             } else {
                 CCUtility.copyFile(atPath: fileNamePath, toPath: fileNameTemp)
-                let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNameTemp), isEditingEnabled: true, isCropEnabled: false, metadata: metadata)
                 appDelegate.window?.rootViewController?.present(viewerQuickLook, animated: true)
             }
 

+ 1 - 1
iOSClient/Settings/CCAdvanced.m

@@ -153,7 +153,7 @@
         row.action.formBlock = ^(XLFormRowDescriptor * sender) {
                     
             [self deselectFormRow:sender];
-            NCViewerQuickLook *viewerQuickLook = [[NCViewerQuickLook alloc] initWith:[NSURL fileURLWithPath:NKCommon.shared.filenamePathLog] isEditingEnabled:false isCropEnabled:false metadata:nil];
+            NCViewerQuickLook *viewerQuickLook = [[NCViewerQuickLook alloc] initWith:[NSURL fileURLWithPath:NKCommon.shared.filenamePathLog] isEditingEnabled:false metadata:nil];
             [self presentViewController:viewerQuickLook animated:YES completion:nil];
         };
         [section addFormRow:row];

+ 1 - 1
iOSClient/Viewer/NCViewer.swift

@@ -235,7 +235,7 @@ class NCViewer: NSObject {
         if QLPreviewController.canPreview(item as QLPreviewItem) {
             let fileNamePath = NSTemporaryDirectory() + metadata.fileNameView
             CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath)
-            let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), isEditingEnabled: false, isCropEnabled: false, metadata: metadata)
+            let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), isEditingEnabled: false, metadata: metadata)
             viewController.present(viewerQuickLook, animated: true)
         } else {
         // Document Interaction Controller

+ 16 - 5
iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift

@@ -38,18 +38,18 @@ private var hasChangesQuickLook: Bool = false
     let url: URL
     var previewItems: [PreviewItem] = []
     var isEditingEnabled: Bool
-    var isCropEnabled: Bool
     var metadata: tableMetadata?
     var timer: Timer?
+    // used to display the save alert
+    var parentVC: UIViewController?
 
     required init?(coder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
 
-    @objc init(with url: URL, isEditingEnabled: Bool, isCropEnabled: Bool, metadata: tableMetadata?) {
+    @objc init(with url: URL, isEditingEnabled: Bool, metadata: tableMetadata?) {
         self.url = url
         self.isEditingEnabled = isEditingEnabled
-        self.isCropEnabled = isCropEnabled
         if let metadata = metadata {
             self.metadata = tableMetadata.init(value: metadata)
         }
@@ -75,7 +75,7 @@ private var hasChangesQuickLook: Bool = false
             NCContentPresenter.shared.showInfo(error: error)
         }
 
-        if isCropEnabled {
+        //if isImage {
             let buttonDone = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(dismission))
             if metadata?.classFile == NKCommon.typeClassFile.image.rawValue {
                 let buttonCrop = UIBarButtonItem(image: UIImage(systemName: "crop"), style: .plain, target: self, action: #selector(crop))
@@ -84,7 +84,18 @@ private var hasChangesQuickLook: Bool = false
                 navigationItem.leftBarButtonItems = [buttonDone]
             }
             startTimer(navigationItem: navigationItem)
-        }
+    }
+
+    override func viewDidAppear(_ animated: Bool) {
+        super.viewDidAppear(animated)
+        // needs to be saved bc in didDisappear presentingVC is already nil
+        parentVC = presentingViewController
+    }
+
+    override func viewDidDisappear(_ animated: Bool) {
+        super.viewDidDisappear(animated)
+
+        dismission()
     }
 
     func startTimer(navigationItem: UINavigationItem) {