1+ import FirebaseCore
12import SwiftUI
23
34@MainActor
4- public struct AuthPickerView < Content : View > {
5+ public struct AuthPickerView {
56 @Environment ( AuthService . self) private var authService
6- let providerButtons : ( ) -> Content
77
8- public init ( @ViewBuilder providerButtons: @escaping ( ) -> Content ) {
9- self . providerButtons = providerButtons
10- }
8+ public init ( ) { }
119
1210 private func switchFlow( ) {
1311 authService. authenticationFlow = authService
@@ -29,34 +27,43 @@ extension AuthPickerView: View {
2927 } else if authService. authView == . emailLink {
3028 EmailLinkView ( )
3129 } else {
32- Text ( authService. authenticationFlow == . login ? authService. string
33- . emailLoginFlowLabel : authService. string. emailSignUpFlowLabel)
34- VStack { Divider ( ) }
35-
36- EmailAuthView ( )
30+ if authService. emailSignInEnabled {
31+ Text ( authService. authenticationFlow == . login ? authService. string
32+ . emailLoginFlowLabel : authService. string. emailSignUpFlowLabel)
33+ Divider ( )
34+ EmailAuthView ( )
35+ }
3736 VStack {
3837 authService. renderButtons ( )
3938 } . padding ( . horizontal)
40-
41- VStack { Divider ( ) }
42- HStack {
43- Text ( authService
44- . authenticationFlow == . login ? authService. string. dontHaveAnAccountYetLabel :
45- authService. string. alreadyHaveAnAccountLabel)
46- Button ( action: {
47- withAnimation {
48- switchFlow ( )
39+ if authService. emailSignInEnabled {
40+ Divider ( )
41+ HStack {
42+ Text ( authService
43+ . authenticationFlow == . login ? authService. string. dontHaveAnAccountYetLabel :
44+ authService. string. alreadyHaveAnAccountLabel)
45+ Button ( action: {
46+ withAnimation {
47+ switchFlow ( )
48+ }
49+ } ) {
50+ Text ( authService. authenticationFlow == . signUp ? authService. string
51+ . emailLoginFlowLabel : authService. string. emailSignUpFlowLabel)
52+ . fontWeight ( . semibold)
53+ . foregroundColor ( . blue)
4954 }
50- } ) {
51- Text ( authService. authenticationFlow == . signUp ? authService. string
52- . emailLoginFlowLabel : authService. string. emailSignUpFlowLabel)
53- . fontWeight ( . semibold)
54- . foregroundColor ( . blue)
5555 }
56+ PrivacyTOCsView ( displayMode: . footer)
57+ Text ( authService. errorMessage) . foregroundColor ( . red)
5658 }
57- PrivacyTOCsView ( displayMode: . footer)
58- Text ( authService. errorMessage) . foregroundColor ( . red)
5959 }
6060 }
6161 }
6262}
63+
64+ #Preview {
65+ FirebaseOptions . dummyConfigurationForPreview ( )
66+ let authService = AuthService ( )
67+ . withEmailSignIn ( )
68+ return AuthPickerView ( ) . environment ( authService)
69+ }
0 commit comments