|
@@ -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) { }
|
|
|
+}
|