File tree Expand file tree Collapse file tree
FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ public enum AuthenticationFlow {
2525 case signUp
2626}
2727
28+ public enum AuthView {
29+ case authPicker
30+ case passwordRecovery
31+ case emailLink
32+ }
33+
2834public enum AuthServiceError : Error {
2935 case invalidEmailLink( String )
3036 case notConfiguredProvider( String )
@@ -77,7 +83,7 @@ public final class AuthService {
7783 @ObservationIgnored @AppStorage ( " email-link " ) public var emailLink : String ?
7884 public let configuration : AuthConfiguration
7985 public let auth : Auth
80-
86+ public var authView : AuthView = . authPicker
8187 public let string : StringUtils
8288 public var currentUser : User ?
8389 public var authenticationState : AuthenticationState = . unauthenticated
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ extension AuthPickerView: View {
2020 VStack {
2121 if authService. authenticationState == . authenticated {
2222 SignedInView ( )
23+ } else if authService. authView == . passwordRecovery {
24+ PasswordRecoveryView ( )
25+ } else if authService. authView == . emailLink {
26+ EmailLinkView ( )
2327 } else {
2428 Text ( authService. authenticationFlow == . login ? " Login " : " Sign up " )
2529 VStack { Divider ( ) }
Original file line number Diff line number Diff line change @@ -90,10 +90,11 @@ extension EmailAuthView: View {
9090 . padding ( . bottom, 8 )
9191
9292 if authService. authenticationFlow == . login {
93- NavigationLink ( destination: PasswordRecoveryView ( )
94- . environment ( authService) ) {
95- Text ( " Forgotten Password? " )
96- }
93+ Button ( action: {
94+ authService. authView = . passwordRecovery
95+ } ) {
96+ Text ( " Forgotten Password? " )
97+ }
9798 }
9899
99100 if authService. authenticationFlow == . signUp {
@@ -133,10 +134,11 @@ extension EmailAuthView: View {
133134 . padding ( [ . top, . bottom] , 8 )
134135 . frame ( maxWidth: . infinity)
135136 . buttonStyle ( . borderedProminent)
136- NavigationLink ( destination: EmailLinkView ( ) . environment ( authService)
137- . environment ( authService) ) {
138- Text ( " Prefer Email link sign-in? " )
139- }
137+ Button ( action: {
138+ authService. authView = . passwordRecovery
139+ } ) {
140+ Text ( " Prefer Email link sign-in? " )
141+ }
140142 }
141143 }
142144}
Original file line number Diff line number Diff line change @@ -64,5 +64,13 @@ extension EmailLinkView: View {
6464 } catch { }
6565 }
6666 }
67+ . navigationBarItems ( leading: Button ( action: {
68+ authService. authView = . authPicker
69+ } ) {
70+ Image ( systemName: " chevron.left " )
71+ . foregroundColor ( . blue)
72+ Text ( " Back " )
73+ . foregroundColor ( . blue)
74+ } )
6775 }
6876}
Original file line number Diff line number Diff line change @@ -57,5 +57,13 @@ extension PasswordRecoveryView: View {
5757 } . onOpenURL { _ in
5858 // move the user to email/password View
5959 }
60+ . navigationBarItems ( leading: Button ( action: {
61+ authService. authView = . authPicker
62+ } ) {
63+ Image ( systemName: " chevron.left " )
64+ . foregroundColor ( . blue)
65+ Text ( " Back " )
66+ . foregroundColor ( . blue)
67+ } )
6068 }
6169}
You can’t perform that action at this time.
0 commit comments