Files
TaskHybrid/salesbook.Maui/Platforms/iOS/Core/FilePreviewService.cs
2025-12-30 17:40:08 +01:00

24 lines
843 B
C#

using QuickLook;
using salesbook.Maui.Core.Interface;
using salesbook.Maui.Helpers;
using UIKit;
namespace salesbook.Maui.Core;
public class FilePreviewService : IFilePreviewService
{
public Task Preview(string fileName, string filePath)
{
var currentController = UIApplication.SharedApplication.KeyWindow?.RootViewController;
while (currentController?.PresentedViewController != null)
currentController = currentController.PresentedViewController;
var currentView = currentController?.View;
var qLPreview = new QLPreviewController();
var item = new QlPreviewItemBundle(fileName, filePath);
qLPreview.DataSource = new PreviewControllerDs(item);
currentController?.PresentViewController(qLPreview, true, null);
return Task.CompletedTask;
}
}