Add lead workflows, PDF signing, AR projects and photo gallery integration
This commit is contained in:
52
GasTankAR/Views/Leads/Shared/LeadDocumentPreview.swift
Normal file
52
GasTankAR/Views/Leads/Shared/LeadDocumentPreview.swift
Normal file
@ -0,0 +1,52 @@
|
||||
import SwiftUI
|
||||
import QuickLook
|
||||
|
||||
/// Native full-screen PDF reading, including zoom, page navigation and system open-in actions.
|
||||
struct LeadDocumentPreview: View {
|
||||
let url: URL
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
LeadQuickLookView(url: url)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .confirmationAction) {
|
||||
Button(role: .confirm) { dismiss() }
|
||||
.labelStyle(.iconOnly)
|
||||
.accessibilityLabel("Zurück zur Unterschrift")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct LeadQuickLookView: UIViewControllerRepresentable {
|
||||
let url: URL
|
||||
|
||||
func makeUIViewController(context: Context) -> QLPreviewController {
|
||||
let controller = QLPreviewController()
|
||||
controller.dataSource = context.coordinator
|
||||
return controller
|
||||
}
|
||||
|
||||
func updateUIViewController(_ controller: QLPreviewController, context: Context) {
|
||||
guard context.coordinator.url != url else { return }
|
||||
context.coordinator.url = url
|
||||
controller.reloadData()
|
||||
}
|
||||
|
||||
func makeCoordinator() -> Coordinator { Coordinator(url: url) }
|
||||
|
||||
final class Coordinator: NSObject, QLPreviewControllerDataSource {
|
||||
var url: URL
|
||||
|
||||
init(url: URL) { self.url = url }
|
||||
|
||||
func numberOfPreviewItems(in controller: QLPreviewController) -> Int { 1 }
|
||||
|
||||
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> any QLPreviewItem {
|
||||
url as NSURL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user