Add lead workflows, PDF signing, AR projects and photo gallery integration
This commit is contained in:
47
GasTankAR/Views/Leads/Detail/LeadARProjectsSheet.swift
Normal file
47
GasTankAR/Views/Leads/Detail/LeadARProjectsSheet.swift
Normal file
@ -0,0 +1,47 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
/// Composition boundary: the AR picker receives only neutral project data.
|
||||
struct LeadARProjectsSheet: View {
|
||||
let detail: LeadDetail
|
||||
@Environment(\.modelContext) private var context
|
||||
@State private var service: LeadARProjectsService?
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if let service {
|
||||
LeadARProjectsContent(service: service)
|
||||
} else {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
.task {
|
||||
if service == nil {
|
||||
service = LeadARProjectsService(detail: detail, container: context.container)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct LeadARProjectsContent: View {
|
||||
let service: LeadARProjectsService
|
||||
@State private var activeProject: Project?
|
||||
@State private var errorMessage: String?
|
||||
|
||||
var body: some View {
|
||||
ARProjectsSheet(service: service) { id in
|
||||
do { activeProject = try service.resolveProject(id: id) }
|
||||
catch { errorMessage = error.localizedDescription }
|
||||
}
|
||||
.fullScreenCover(item: $activeProject) { project in
|
||||
if let context = project.modelContext {
|
||||
ARExperienceView(project: project).modelContext(context)
|
||||
}
|
||||
}
|
||||
.alert("AR-Projekt konnte nicht geöffnet werden",
|
||||
isPresented: Binding(get: { errorMessage != nil },
|
||||
set: { if !$0 { errorMessage = nil } })) {
|
||||
Button("OK", role: .cancel) { errorMessage = nil }
|
||||
} message: { Text(errorMessage ?? "") }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user