@@ -181,29 +181,34 @@ class NCViewer: NSObject {
181181
182182 return vc
183183 }
184- }
185- }
186- // QLPreview
187- else {
188- let item = URL ( fileURLWithPath: utilityFileSystem. getDirectoryProviderStorageOcId ( metadata. ocId,
189- fileName: metadata. fileNameView,
190- userId: metadata. userId,
191- urlBase: metadata. urlBase) )
192- if QLPreviewController . canPreview ( item as QLPreviewItem ) {
193- let fileNamePath = NSTemporaryDirectory ( ) + metadata. fileNameView
194- utilityFileSystem. copyFile ( atPath: utilityFileSystem. getDirectoryProviderStorageOcId ( metadata. ocId,
195- fileName: metadata. fileNameView,
196- userId: metadata. userId,
197- urlBase: metadata. urlBase) , toPath: fileNamePath)
198- let viewerQuickLook = NCViewerQuickLook ( with: URL ( fileURLWithPath: fileNamePath) , isEditingEnabled: false , metadata: metadata)
199- delegate? . present ( viewerQuickLook, animated: true )
200184 } else {
201- // Document Interaction Controller
202- if let controller = delegate? . tabBarController as? NCMainTabBarController {
203- NCDownloadAction . shared. openActivityViewController ( selectedMetadata: [ metadata] , controller: controller, sender: nil )
204- }
185+ self . QLPreview ( metadata: metadata, delegate: delegate)
205186 }
187+ } else {
188+ self . QLPreview ( metadata: metadata, delegate: delegate)
206189 }
190+
207191 return nil
208192 }
193+
194+ func QLPreview( metadata: tableMetadata , delegate: UIViewController ? = nil ) {
195+ let item = URL ( fileURLWithPath: utilityFileSystem. getDirectoryProviderStorageOcId ( metadata. ocId,
196+ fileName: metadata. fileNameView,
197+ userId: metadata. userId,
198+ urlBase: metadata. urlBase) )
199+ if QLPreviewController . canPreview ( item as QLPreviewItem ) {
200+ let fileNamePath = NSTemporaryDirectory ( ) + metadata. fileNameView
201+ utilityFileSystem. copyFile ( atPath: utilityFileSystem. getDirectoryProviderStorageOcId ( metadata. ocId,
202+ fileName: metadata. fileNameView,
203+ userId: metadata. userId,
204+ urlBase: metadata. urlBase) , toPath: fileNamePath)
205+ let viewerQuickLook = NCViewerQuickLook ( with: URL ( fileURLWithPath: fileNamePath) , isEditingEnabled: false , metadata: metadata)
206+ delegate? . present ( viewerQuickLook, animated: true )
207+ } else {
208+ // Document Interaction Controller
209+ if let controller = delegate? . tabBarController as? NCMainTabBarController {
210+ NCDownloadAction . shared. openActivityViewController ( selectedMetadata: [ metadata] , controller: controller, sender: nil )
211+ }
212+ }
213+ }
209214}
0 commit comments