mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-01 05:36:57 +02:00
Inject AvatarViewMode as EnvironmentObject
This commit is contained in:
@@ -31,18 +31,3 @@ extension EnvironmentValues {
|
||||
set { self[DependencyContainerKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
/// A modifier for adding a dependency to the SwiftUI view hierarchy's dependency container.
|
||||
///
|
||||
/// Important: When adding a dependency to cast it to the type in which it will be injected.
|
||||
/// So if adding `MockDependency` but type at injection is `Dependency` remember to cast
|
||||
/// to `Dependency` first.
|
||||
/// - Parameter dependency: The dependency to add.
|
||||
/// - Returns: The wrapped view that now includes the dependency.
|
||||
func addDependency<T>(_ dependency: T) -> some View {
|
||||
transformEnvironment(\.dependencies) { container in
|
||||
container.register(dependency: dependency)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user