Skip to content

Commit c013f34

Browse files
refactor: use switch statement
1 parent 03ebaf2 commit c013f34

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/AuthPickerView.swift

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,39 +30,44 @@ extension AuthPickerView: View {
3030
authPickerTitleView
3131
if authService.authenticationState == .authenticated {
3232
SignedInView()
33-
} else if authService.authView == .passwordRecovery {
34-
PasswordRecoveryView()
35-
} else if authService.authView == .emailLink {
36-
EmailLinkView()
3733
} else {
38-
if authService.emailSignInEnabled {
39-
Text(authService.authenticationFlow == .login ? authService.string
40-
.emailLoginFlowLabel : authService.string.emailSignUpFlowLabel)
41-
Divider()
42-
EmailAuthView()
43-
}
44-
VStack {
45-
authService.renderButtons()
46-
}.padding(.horizontal)
47-
if authService.emailSignInEnabled {
48-
Divider()
49-
HStack {
50-
Text(authService
51-
.authenticationFlow == .login ? authService.string.dontHaveAnAccountYetLabel :
52-
authService.string.alreadyHaveAnAccountLabel)
53-
Button(action: {
54-
withAnimation {
55-
switchFlow()
34+
switch authService.authView {
35+
case .passwordRecovery:
36+
PasswordRecoveryView()
37+
case .emailLink:
38+
EmailLinkView()
39+
case .authPicker:
40+
if authService.emailSignInEnabled {
41+
Text(authService.authenticationFlow == .login ? authService.string
42+
.emailLoginFlowLabel : authService.string.emailSignUpFlowLabel)
43+
Divider()
44+
EmailAuthView()
45+
}
46+
VStack {
47+
authService.renderButtons()
48+
}.padding(.horizontal)
49+
if authService.emailSignInEnabled {
50+
Divider()
51+
HStack {
52+
Text(authService
53+
.authenticationFlow == .login ? authService.string.dontHaveAnAccountYetLabel :
54+
authService.string.alreadyHaveAnAccountLabel)
55+
Button(action: {
56+
withAnimation {
57+
switchFlow()
58+
}
59+
}) {
60+
Text(authService.authenticationFlow == .signUp ? authService.string
61+
.emailLoginFlowLabel : authService.string.emailSignUpFlowLabel)
62+
.fontWeight(.semibold)
63+
.foregroundColor(.blue)
5664
}
57-
}) {
58-
Text(authService.authenticationFlow == .signUp ? authService.string
59-
.emailLoginFlowLabel : authService.string.emailSignUpFlowLabel)
60-
.fontWeight(.semibold)
61-
.foregroundColor(.blue)
6265
}
6366
}
6467
PrivacyTOCsView(displayMode: .footer)
6568
Text(authService.errorMessage).foregroundColor(.red)
69+
default:
70+
EmptyView()
6671
}
6772
}
6873
}

0 commit comments

Comments
 (0)