Files
zeekayandHanzo Dev c8bfbebc15 Keep ZAMA's copyright notices
This app is ZAMA's BSD 3-Clause Clear demo. The license requires its notices to
survive redistribution, and a rebrand had replaced every one of them with ours:
the LICENSE text, 66 source headers and the app's copyright string. They are
back, each with our line beside it for our changes.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-23 01:55:03 -07:00

46 lines
1.1 KiB
Swift

// Copyright © 2025 Zama. All rights reserved.
// Copyright © 2025 Lux Industries Inc.
import SwiftUI
import QuickLook
struct FilePreview: UIViewControllerRepresentable {
let url: URL
func makeUIViewController(context: Context) -> UIViewController {
let vc = QLPreviewController()
vc.dataSource = context.coordinator
return vc
}
func updateUIViewController(_ vc: UIViewController, context _: Context) {
(vc as! QLPreviewController).reloadData()
}
func makeCoordinator() -> Coordinator {
Coordinator(parent: self)
}
final class Coordinator: QLPreviewControllerDataSource {
let parent: FilePreview
init(parent: FilePreview) {
self.parent = parent
}
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
1
}
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
parent.url as NSURL
}
}
}
#Preview {
FilePreview(url: Bundle.main.bundleURL)
.border(.secondary)
.padding()
}