Ver Fonte

Remove custom QuickLook Done button

Only default don't button calls `didSaveEditedCopyOf` delegate method. With custom done button last changes will be discarded

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch há 3 anos atrás
pai
commit
1f84988aec

+ 1 - 4
iOSClient/Main/NCFunctionCenter.swift

@@ -78,10 +78,7 @@ import SVGKit
             }
 
             let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), editingMode: editingMode, metadata: metadata)
-            let navigationController = UINavigationController(rootViewController: viewerQuickLook)
-            navigationController.modalPresentationStyle = .overFullScreen
-
-            self.appDelegate.window?.rootViewController?.present(navigationController, animated: true)
+            self.appDelegate.window?.rootViewController?.present(viewerQuickLook, animated: true)
 
         case NCGlobal.shared.selectorLoadFileView:
             guard UIApplication.shared.applicationState == UIApplication.State.active else { break }

+ 1 - 4
iOSClient/Viewer/NCViewer.swift

@@ -209,10 +209,7 @@ class NCViewer: NSObject {
         CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath)
 
         let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), editingMode: false, metadata: metadata)
-        let navigationController = UINavigationController(rootViewController: viewerQuickLook)
-        navigationController.modalPresentationStyle = .overFullScreen
-
-        viewController.present(navigationController, animated: true)
+        viewController.present(viewerQuickLook, animated: true)
     }
 }
 

+ 2 - 12
iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift

@@ -60,8 +60,6 @@ import NCCommunication
         self.dataSource = self
         self.delegate = self
         self.currentPreviewItemIndex = 0
-
-        self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(dismissPreviewController))
     }
 
     override func viewDidLoad() {
@@ -95,8 +93,8 @@ import NCCommunication
         }
     }
 
-    @objc func dismissPreviewController() {
-
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
         if editingMode {
 
             let alertController = UIAlertController(title: NSLocalizedString("_save_", comment: ""), message: "", preferredStyle: .alert)
@@ -104,27 +102,19 @@ import NCCommunication
             if metadata?.livePhoto == false {
                 alertController.addAction(UIAlertAction(title: NSLocalizedString("_overwrite_original_", comment: ""), style: .default) { (_: UIAlertAction) in
                     self.saveMode = .overwrite
-                    self.dismiss(animated: true)
                 })
             }
 
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_save_as_copy_", comment: ""), style: .default) { (_: UIAlertAction) in
                 self.saveMode = .copy
-                self.dismiss(animated: true)
             })
 
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_discard_changes_", comment: ""), style: .destructive) { (_: UIAlertAction) in
                 self.saveMode = .discard
-                self.dismiss(animated: true)
             })
 
             alertController.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel) { (_: UIAlertAction) in })
 
-            self.present(alertController, animated: true)
-
-        } else {
-
-            self.dismiss(animated: true)
         }
     }
 }