diff --git a/Sources/SpeziFirebaseAccount/Views/FirebaseAccountModifier.swift b/Sources/SpeziFirebaseAccount/Views/FirebaseAccountModifier.swift index f3c66f6..3a985b8 100644 --- a/Sources/SpeziFirebaseAccount/Views/FirebaseAccountModifier.swift +++ b/Sources/SpeziFirebaseAccount/Views/FirebaseAccountModifier.swift @@ -12,28 +12,40 @@ import SwiftUI struct FirebaseAccountModifier: ViewModifier { + private let enable: Bool + @EnvironmentObject private var account: Account @Environment(\.authorizationController) private var authorizationController + + init(_ enable: Bool) { + self.enable = enable + } + + func body(content: Content) -> some View { - content - .task { - for service in account.registeredAccountServices { - guard let firebaseService = service as? any FirebaseAccountService else { - continue + if enable { + content + .task { + for service in account.registeredAccountServices { + guard let firebaseService = service as? any FirebaseAccountService else { + continue + } + + await firebaseService.inject(authorizationController: authorizationController) } - - await firebaseService.inject(authorizationController: authorizationController) } - } + } else { + content + } } } extension View { - public func firebaseAccount() -> some View { - modifier(FirebaseAccountModifier()) + public func firebaseAccount(_ enable: Bool = true) -> some View { + modifier(FirebaseAccountModifier(enable)) } }