Files
Gas-Tank-AR-App/GasTankAR/Views/SettingsView.swift
2026-11-07 18:38:35 +01:00

105 lines
3.6 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// SettingsView.swift
// GasTankAR
//
// Created by Dennis Nemec on 26.08.26.
//
import SwiftUI
import ARKit
/// Zentrale Schlüssel für AppStorage/UserDefaults.
enum SettingsKeys {
static let lidarFeaturesEnabled = "lidarFeaturesEnabled"
static let arExposure = "arExposure"
static let devTankResizingEnabled = "devTankResizingEnabled"
}
/// Eine gespeicherte Entwickler-Option darf in Release niemals die Tankgröße ändern.
enum TankResizePolicy {
static func isEnabled(devFlag: Bool) -> Bool {
#if DEBUG
devFlag
#else
false
#endif
}
}
struct SettingsView: View {
@AppStorage(SettingsKeys.lidarFeaturesEnabled) private var lidarEnabled = false
@AppStorage(SettingsKeys.arExposure) private var arExposure = 1.0
#if DEBUG
@AppStorage(SettingsKeys.devTankResizingEnabled) private var devTankResizingEnabled = false
#endif
@Environment(\.dismiss) private var dismiss
/// LiDAR ist verfügbar, wenn das Gerät Scene-Reconstruction (Mesh) unterstützt.
private var lidarSupported: Bool {
ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh)
}
var body: some View {
NavigationStack {
Form {
Section {
Toggle("LiDAR-Funktionen aktivieren", isOn: $lidarEnabled)
.disabled(!lidarSupported)
} header: {
Text("Augmented Reality")
} footer: {
if lidarSupported {
Text("Nutzt den LiDAR-Scanner für präzisere Flächenerkennung, Tiefe und realistische Verdeckung. Änderungen greifen beim nächsten Start des AR-Modus.")
} else {
Text("Dieses Gerät hat keinen LiDAR-Scanner. Die App nutzt automatisch das Verfahren ohne LiDAR.")
}
}
Section {
HStack {
Text("Belichtung")
Spacer()
Text(arExposure.formatted(.number.precision(.fractionLength(1))) + "×")
.foregroundStyle(.secondary)
.monospacedDigit()
}
Slider(value: $arExposure, in: 0.5...2.0, step: 0.1)
.accessibilityLabel("AR-Belichtung")
.accessibilityValue(arExposure.formatted(.number.precision(.fractionLength(1))) + " mal")
} header: {
Text("Darstellung")
} footer: {
Text("Passt die zusätzliche Beleuchtung der oberirdischen Tanks an. Änderungen greifen beim nächsten Start des AR-Modus.")
}
#if DEBUG
Section {
Toggle("Tankgröße per Geste ändern", isOn: $devTankResizingEnabled)
} header: {
Text("Entwicklung")
} footer: {
Text("Nur im Debug-Build verfügbar. Die Änderung greift beim nächsten Start des AR-Modus.")
}
#endif
Section {
NavigationLink {
HelpView()
} label: {
Label("Hilfe", systemImage: "questionmark.circle")
}
}
}
.navigationTitle("Einstellungen")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Fertig") { dismiss() }
}
}
}
}
}
#Preview {
SettingsView()
}