Browse Source

add ViewerQuickLook

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 2 years ago
parent
commit
c9266847d0
1 changed files with 44 additions and 0 deletions
  1. 44 0
      iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift

+ 44 - 0
iOSClient/Viewer/NCViewerQuickLook/NCViewerQuickLook.swift

@@ -28,6 +28,7 @@ import UIKit
 import QuickLook
 import NextcloudKit
 import Mantis
+import SwiftUI
 
 protocol NCViewerQuickLookDelegate: AnyObject {
     func dismiss(url: URL, hasChanges: Bool)
@@ -223,3 +224,46 @@ extension NCViewerQuickLook: CropViewControllerDelegate {
 class PreviewItem: NSObject, QLPreviewItem {
     var previewItemURL: URL?
 }
+
+// MARK: - UIViewControllerRepresentable
+
+struct ViewerQuickLook: UIViewControllerRepresentable {
+
+    typealias UIViewControllerType = NCViewerQuickLook
+
+    // let fileNamePath = NSTemporaryDirectory() + metadata.fileNameView
+    // CCUtility.copyFile(atPath: CCUtility.getDirectoryProviderStorageOcId(metadata.ocId, fileNameView: metadata.fileNameView), toPath: fileNamePath)
+
+    @Binding var fileNamePath: String
+    @Binding var metadata: tableMetadata?
+
+    @Environment(\.presentationMode) var presentationMode
+
+    class Coordinator: NCViewerQuickLookDelegate {
+
+        var parent: ViewerQuickLook
+        var isModified: Bool = false
+
+        init(_ parent: ViewerQuickLook) {
+            self.parent = parent
+        }
+
+        // DELEGATE
+
+        func dismiss(url: URL, hasChanges: Bool) {
+
+        }
+    }
+
+    func makeCoordinator() -> Coordinator {
+        Coordinator(self)
+    }
+
+    func makeUIViewController(context: Context) -> UIViewControllerType {
+        let viewerQuickLook = NCViewerQuickLook(with: URL(fileURLWithPath: fileNamePath), isEditingEnabled: true, metadata: metadata)
+        viewerQuickLook.delegateViewer = context.coordinator
+        return viewerQuickLook
+    }
+
+    func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) { }
+}