Files
Gas-Tank-AR-App/GasTankAR/Views/TankAR/ARControlOverlay.swift
2026-09-02 20:54:36 +02:00

84 lines
2.6 KiB
Swift

//
// ARControlOverlay.swift
// GasTankAR
//
// Created by Dennis Nemec on 27.08.26.
//
import SwiftUI
/// Runde Werkzeug-Buttons oben rechts über der AR-View. Untereinander angeordnet;
/// weitere Funktionen lassen sich als zusätzliche `roundButton` ergänzen.
struct ARControlOverlay: View {
let controller: ARSessionController
/// Öffnet die Strecken-Liste (Ausmessen).
let onMeasure: () -> Void
var body: some View {
VStack {
HStack {
Spacer()
VStack(spacing: 12) {
roundButton(
systemImage: "shield.lefthalf.filled",
isActive: controller.showSafetyZones,
label: "Sicherheitsabstand"
) {
controller.toggleSafetyZones()
}
roundButton(
systemImage: "ruler",
isActive: controller.measurementPhase != .idle,
label: "Ausmessen"
) {
onMeasure()
}
roundButton(
systemImage: "point.3.connected.trianglepath.dotted",
isActive: controller.pipeRoutingPhase != .idle,
label: "Rohrführung"
) {
if controller.pipeRoutingPhase == .idle {
controller.startPipeRouting()
}
}
roundButton(
systemImage: "camera.fill",
isActive: false,
label: "Foto aufnehmen"
) {
controller.captureSnapshot()
}
}
}
Spacer()
}
.padding()
}
private func roundButton(
systemImage: String,
isActive: Bool,
label: String,
action: @escaping () -> Void
) -> some View {
Button(action: action) {
Image(systemName: systemImage)
.font(.title3)
.frame(width: 52, height: 52)
.foregroundStyle(isActive ? Color.white : Color.primary)
.background(
isActive ? AnyShapeStyle(Color.accentColor) : AnyShapeStyle(.ultraThinMaterial),
in: .circle
)
.shadow(radius: 3)
}
.buttonStyle(.plain)
.accessibilityLabel(label)
.accessibilityAddTraits(isActive ? .isSelected : [])
}
}