@@ -58,6 +58,79 @@ public struct EmailPasswordView {
5858
5959extension EmailPasswordView : View {
6060 public var body : some View {
61- Text ( " EmailPasswordView " )
61+ VStack {
62+ LabeledContent {
63+ TextField ( " Email " , text: $email)
64+ . textInputAutocapitalization ( . never)
65+ . disableAutocorrection ( true )
66+ . focused ( $focus, equals: . email)
67+ . submitLabel ( . next)
68+ . onSubmit {
69+ self . focus = . password
70+ }
71+ } label: {
72+ Image ( systemName: " at " )
73+ }
74+ . padding ( . vertical, 6 )
75+ . background ( Divider ( ) , alignment: . bottom)
76+ . padding ( . bottom, 4 )
77+
78+ LabeledContent {
79+ SecureField ( " Password " , text: $password)
80+ . focused ( $focus, equals: . password)
81+ . submitLabel ( . go)
82+ . onSubmit {
83+ Task { await signInWithEmailPassword ( ) }
84+ }
85+ } label: {
86+ Image ( systemName: " lock " )
87+ }
88+ . padding ( . vertical, 6 )
89+ . background ( Divider ( ) , alignment: . bottom)
90+ . padding ( . bottom, 8 )
91+
92+ if authEnvironment. authenticationFlow == . login {
93+ Button ( " Forgot password? " ) { }
94+ . frame ( maxWidth: . infinity, alignment: . trailing)
95+ }
96+
97+ if authEnvironment. authenticationFlow == . signUp {
98+ LabeledContent {
99+ SecureField ( " Confirm password " , text: $confirmPassword)
100+ . focused ( $focus, equals: . confirmPassword)
101+ . submitLabel ( . go)
102+ . onSubmit {
103+ Task { await signUpWithEmailPassword ( ) }
104+ }
105+ } label: {
106+ Image ( systemName: " lock " )
107+ }
108+ . padding ( . vertical, 6 )
109+ . background ( Divider ( ) , alignment: . bottom)
110+ . padding ( . bottom, 8 )
111+ }
112+
113+ Button ( action: {
114+ Task {
115+ if authEnvironment. authenticationFlow == . login { await signInWithEmailPassword ( ) }
116+ else { await signUpWithEmailPassword ( ) }
117+ }
118+ } ) {
119+ if authEnvironment. authenticationState != . authenticating {
120+ Text ( authEnvironment. authenticationFlow == . login ? " Log in with password " : " Sign up " )
121+ . padding ( . vertical, 8 )
122+ . frame ( maxWidth: . infinity)
123+ } else {
124+ ProgressView ( )
125+ . progressViewStyle ( CircularProgressViewStyle ( tint: . white) )
126+ . padding ( . vertical, 8 )
127+ . frame ( maxWidth: . infinity)
128+ }
129+ }
130+ . disabled ( !isValid)
131+ . padding ( [ . top, . bottom] , 8 )
132+ . frame ( maxWidth: . infinity)
133+ . buttonStyle ( . borderedProminent)
134+ }
62135 }
63136}
0 commit comments