1
+ import FirebaseCore
1
2
import SwiftUI
2
3
3
4
@MainActor
4
- public struct AuthPickerView < Content : View > {
5
+ public struct AuthPickerView {
5
6
@Environment ( AuthService . self) private var authService
6
- let providerButtons : ( ) -> Content
7
7
8
- public init ( @ViewBuilder providerButtons: @escaping ( ) -> Content ) {
9
- self . providerButtons = providerButtons
10
- }
8
+ public init ( ) { }
11
9
12
10
private func switchFlow( ) {
13
11
authService. authenticationFlow = authService
@@ -29,34 +27,43 @@ extension AuthPickerView: View {
29
27
} else if authService. authView == . emailLink {
30
28
EmailLinkView ( )
31
29
} 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
+ }
37
36
VStack {
38
37
authService. renderButtons ( )
39
38
} . 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)
49
54
}
50
- } ) {
51
- Text ( authService. authenticationFlow == . signUp ? authService. string
52
- . emailLoginFlowLabel : authService. string. emailSignUpFlowLabel)
53
- . fontWeight ( . semibold)
54
- . foregroundColor ( . blue)
55
55
}
56
+ PrivacyTOCsView ( displayMode: . footer)
57
+ Text ( authService. errorMessage) . foregroundColor ( . red)
56
58
}
57
- PrivacyTOCsView ( displayMode: . footer)
58
- Text ( authService. errorMessage) . foregroundColor ( . red)
59
59
}
60
60
}
61
61
}
62
62
}
63
+
64
+ #Preview {
65
+ FirebaseOptions . dummyConfigurationForPreview ( )
66
+ let authService = AuthService ( )
67
+ . withEmailSignIn ( )
68
+ return AuthPickerView ( ) . environment ( authService)
69
+ }
0 commit comments