diff --git a/iosApp/iosApp/Environment/DataManagerEnvironment.swift b/iosApp/iosApp/Environment/DataManagerEnvironment.swift new file mode 100644 index 0000000..2590309 --- /dev/null +++ b/iosApp/iosApp/Environment/DataManagerEnvironment.swift @@ -0,0 +1,31 @@ +import SwiftUI +import ComposeApp + +/// SwiftUI `@Environment` mirror of Compose's `LocalDataManager` ambient. +/// +/// Production views resolve `@Environment(\.dataManager)` to +/// `DataManagerObservable.shared` — the existing Swift-side mirror of the +/// shared Kotlin `DataManager` singleton. Tests, previews, and the +/// parity-gallery override via: +/// +/// ```swift +/// MyView() +/// .environment(\.dataManager, FakeDataManagerObservable()) +/// ``` +/// +/// This key is intentionally introduced without migrating any SwiftUI +/// screens yet. Views continue to access `DataManagerObservable.shared` +/// directly; the actual view-level migration lands when parity-gallery +/// fixtures arrive (P1), at which point ViewModels will gain an optional +/// init param that accepts a `DataManagerObservable` resolved from this +/// environment key. +struct DataManagerEnvironmentKey: EnvironmentKey { + static let defaultValue: DataManagerObservable = DataManagerObservable.shared +} + +extension EnvironmentValues { + var dataManager: DataManagerObservable { + get { self[DataManagerEnvironmentKey.self] } + set { self[DataManagerEnvironmentKey.self] = newValue } + } +}