Inject AvatarViewMode as EnvironmentObject

This commit is contained in:
Alfonso Grillo
2023-01-13 12:57:21 +01:00
parent 908c911eaf
commit 9df4a5a10b
52 changed files with 70 additions and 74 deletions
@@ -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)
}
}
}