File tree Expand file tree Collapse file tree
FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/FirebaseAuthSwiftUI/Services
samples/swiftui/FirebaseSwiftUIExample/FirebaseSwiftUIExample Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ public final class AuthConfiguration {
4+ var shouldHideCancelButton : Bool
5+ var interactiveDismissEnabled : Bool
6+ var shouldAutoUpgradeAnonymousUsers : Bool
7+ var customStringsBundle : Bundle
8+ var tosUrl : URL
9+ var privacyPolicyUrl : URL
10+
11+ public init ( shouldHideCancelButton: Bool = false ,
12+ interactiveDismissEnabled: Bool = true ,
13+ shouldAutoUpgradeAnonymousUsers: Bool = false ,
14+ customStringsBundle: Bundle = Bundle . main,
15+ tosUrl: URL = URL ( string: " https://example.com/tos " ) !,
16+ privacyPolicyUrl: URL = URL ( string: " https://example.com/privacy " ) !) {
17+ self . shouldHideCancelButton = shouldHideCancelButton
18+ self . interactiveDismissEnabled = interactiveDismissEnabled
19+ self . shouldAutoUpgradeAnonymousUsers = shouldAutoUpgradeAnonymousUsers
20+ self . customStringsBundle = customStringsBundle
21+ self . tosUrl = tosUrl
22+ self . privacyPolicyUrl = privacyPolicyUrl
23+ }
24+ }
Original file line number Diff line number Diff line change @@ -52,22 +52,18 @@ final class AuthListenerManager {
5252@MainActor
5353@Observable
5454public final class AuthEnvironment {
55- public static let shared = AuthEnvironment ( )
56-
57- // TODO: - need to know how we're configuring the below properties or if they should live on AuthEnvironment
58- let auth : Auth = . auth( )
59- let language : String = " en "
60- let enableAutoAnonymousLogin : Bool = true
61-
62- var currentUser : User ?
63- var errorMessage = " "
64-
55+ public let configuation : AuthConfiguration
56+ public let auth : Auth
6557 private var listenerManager : AuthListenerManager ?
6658
67- private init ( ) {
59+ public init ( configuration: AuthConfiguration = AuthConfiguration ( ) , auth: Auth = Auth . auth ( ) ) {
60+ self . auth = auth
61+ configuation = configuration
6862 listenerManager = AuthListenerManager ( auth: auth, authEnvironment: self )
6963 }
7064
65+ public var currentUser : User ?
66+ public var errorMessage = " "
7167 public var authenticationState : AuthenticationState = . unauthenticated
7268 public var authenticationFlow : AuthenticationFlow = . login
7369
Original file line number Diff line number Diff line change @@ -15,12 +15,15 @@ import SwiftUI
1515struct FirebaseSwiftUIExampleApp : App {
1616 init ( ) {
1717 FirebaseApp . configure ( )
18+ authViewModel = AuthEnvironment ( )
1819 }
1920
21+ let authViewModel : AuthEnvironment
22+
2023 var body : some Scene {
2124 WindowGroup {
2225 NavigationView {
23- AuthenticationScreen ( ) . environment ( AuthEnvironment . shared )
26+ AuthenticationScreen ( ) . environment ( authViewModel )
2427 }
2528 }
2629 }
You can’t perform that action at this time.
0 commit comments