Add in-app demo mode toggle, enable alignment assistant in demo data
CAMPER_DEMO=1 only works when Xcode or simctl launches the process, so a build installed locally and opened from the home screen had no way to enable demo mode at all. Demo mode is now also a persisted toggle under Settings > Entwicklung (Debug builds only), checked alongside the environment variable. Takes effect after an app restart since DeviceStore/BluetoothManager only read it at init. Also mark the demo leveling sensor as live-connected - it had a level reading but never a live link state, which left the Ausrichtungs- Assistent button (and Live Activity toggle) disabled in demo mode. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
8d975d2c4d
commit
7fc9442aeb
@@ -280,6 +280,10 @@ final class BluetoothManager: NSObject {
|
|||||||
bluetoothStatusText = "Demo-Modus"
|
bluetoothStatusText = "Demo-Modus"
|
||||||
//fridgeStates[DemoData.fridge.id] = DemoData.fridgeState
|
//fridgeStates[DemoData.fridge.id] = DemoData.fridgeState
|
||||||
levelStates[DemoData.level.id] = DemoData.levelState
|
levelStates[DemoData.level.id] = DemoData.levelState
|
||||||
|
// Ohne "live" bleibt der Ausrichtungs-Assistent (und die Live
|
||||||
|
// Activity) im Demo-Modus deaktiviert, weil beide echte Messwerte
|
||||||
|
// voraussetzen.
|
||||||
|
linkStates[DemoData.level.id] = .live
|
||||||
|
|
||||||
solarStates[DemoData.solar.id] = DemoData.solarState
|
solarStates[DemoData.solar.id] = DemoData.solarState
|
||||||
linkStates[DemoData.solar.id] = .live
|
linkStates[DemoData.solar.id] = .live
|
||||||
|
|||||||
@@ -3,18 +3,30 @@ import Foundation
|
|||||||
/// Füllt die App mit erfundenen Messwerten, damit sich die Ansichten ohne
|
/// Füllt die App mit erfundenen Messwerten, damit sich die Ansichten ohne
|
||||||
/// Fahrzeug und ohne Bluetooth prüfen lassen.
|
/// Fahrzeug und ohne Bluetooth prüfen lassen.
|
||||||
///
|
///
|
||||||
/// Nur in Debug-Builds und nur, wenn beim Start `CAMPER_DEMO=1` gesetzt ist:
|
/// Nur in Debug-Builds, auf zwei Wegen einzuschalten:
|
||||||
///
|
///
|
||||||
/// xcrun simctl launch --terminate-running-process \
|
/// * Umgebungsvariable `CAMPER_DEMO=1` beim Start – praktisch im Simulator:
|
||||||
/// booted de.fritob.CamperMonitor
|
///
|
||||||
/// # mit: SIMCTL_CHILD_CAMPER_DEMO=1 davor
|
/// xcrun simctl launch --terminate-running-process \
|
||||||
|
/// booted de.fritob.CamperMonitor
|
||||||
|
/// # mit: SIMCTL_CHILD_CAMPER_DEMO=1 davor
|
||||||
|
///
|
||||||
|
/// * Schalter in den Einstellungen (`SettingsView`) – der einzige Weg auf
|
||||||
|
/// einem lokal installierten Build ohne Xcode-Verbindung, da sich dort
|
||||||
|
/// keine Umgebungsvariable setzen lässt. Wirkt erst nach einem Neustart der
|
||||||
|
/// App, weil `DeviceStore` und `BluetoothManager` den Stand nur beim Start
|
||||||
|
/// lesen.
|
||||||
///
|
///
|
||||||
/// Im normalen Betrieb wird hiervon nichts ausgeführt.
|
/// Im normalen Betrieb wird hiervon nichts ausgeführt.
|
||||||
enum DemoData {
|
enum DemoData {
|
||||||
|
|
||||||
|
/// Schlüssel für den Einstellungen-Schalter, siehe `SettingsView`.
|
||||||
|
static let enabledKey = "demoModeEnabled"
|
||||||
|
|
||||||
static var isEnabled: Bool {
|
static var isEnabled: Bool {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
return ProcessInfo.processInfo.environment["CAMPER_DEMO"] == "1"
|
if ProcessInfo.processInfo.environment["CAMPER_DEMO"] == "1" { return true }
|
||||||
|
return UserDefaults.standard.bool(forKey: enabledKey)
|
||||||
#else
|
#else
|
||||||
return false
|
return false
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,12 +4,28 @@ import SwiftUI
|
|||||||
/// betrifft, steht bei diesem Gerät.
|
/// betrifft, steht bei diesem Gerät.
|
||||||
struct SettingsView: View {
|
struct SettingsView: View {
|
||||||
@AppStorage(AppSettings.showDiagnosticsKey) private var showDiagnostics = false
|
@AppStorage(AppSettings.showDiagnosticsKey) private var showDiagnostics = false
|
||||||
|
#if DEBUG
|
||||||
|
@AppStorage(DemoData.enabledKey) private var demoModeEnabled = false
|
||||||
|
#endif
|
||||||
@Environment(PhoneWatchLink.self) private var watch
|
@Environment(PhoneWatchLink.self) private var watch
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
List {
|
List {
|
||||||
|
#if DEBUG
|
||||||
|
Section {
|
||||||
|
Toggle("Demo-Modus", isOn: $demoModeEnabled)
|
||||||
|
} header: {
|
||||||
|
Text("Entwicklung")
|
||||||
|
} footer: {
|
||||||
|
Text("Füllt die App mit erfundenen Fahrzeugen und Messwerten, um "
|
||||||
|
+ "Ansichten ohne echte Sensoren zu prüfen. Wirkt erst nach "
|
||||||
|
+ "einem Neustart der App – einmal beenden (im App-Umschalter "
|
||||||
|
+ "nach oben wischen) und wieder öffnen.")
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
Toggle("Diagnose anzeigen", isOn: $showDiagnostics)
|
Toggle("Diagnose anzeigen", isOn: $showDiagnostics)
|
||||||
} header: {
|
} header: {
|
||||||
|
|||||||
Reference in New Issue
Block a user