Skip to content

Commit ffc8436

Browse files
refactor: send email view to match UI and remove surplus file
1 parent 7285f12 commit ffc8436

3 files changed

Lines changed: 60 additions & 80 deletions

File tree

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Utils/StringUtils.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,14 @@ public class StringUtils {
217217

218218
/// Account settings - send email verification label
219219
/// found in:
220-
/// VerifyEmailView
220+
/// SignedInView
221221
public var sendEmailVerificationButtonLabel: String {
222222
return localizedString(for: "Verify email address?")
223223
}
224224

225225
/// Account settings - verify email sheet message
226226
/// found in:
227-
/// VerifyEmailView
227+
/// SignedInView
228228
public var verifyEmailSheetMessage: String {
229229
return localizedString(for: "Verification email sent")
230230
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/SignedInView.swift

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ import SwiftUI
1919
public struct SignedInView {
2020
@Environment(AuthService.self) private var authService
2121
@State private var showDeleteConfirmation = false
22+
@State private var showEmailVerificationSent = false
23+
24+
private func sendEmailVerification() async {
25+
do {
26+
try await authService.sendEmailVerification()
27+
showEmailVerificationSent = true
28+
} catch {
29+
// Error already displayed via modal by AuthService
30+
}
31+
}
2232
}
2333

2434
extension SignedInView: View {
@@ -40,52 +50,68 @@ extension SignedInView: View {
4050
"\(authService.currentUser?.email ?? authService.currentUser?.displayName ?? "Unknown")"
4151
)
4252
if authService.currentUser?.isEmailVerified == false {
43-
VerifyEmailView()
53+
Button {
54+
Task {
55+
await sendEmailVerification()
56+
}
57+
} label: {
58+
Text(authService.string.sendEmailVerificationButtonLabel)
59+
.padding(.vertical, 8)
60+
.frame(maxWidth: .infinity)
61+
}
62+
.buttonStyle(.borderedProminent)
63+
.padding([.top, .bottom], 8)
64+
.frame(maxWidth: .infinity)
65+
.accessibilityIdentifier("verify-email-button")
4466
}
45-
Button(action: {
67+
Button {
4668
authService.navigator.push(.updatePassword)
47-
}) {
69+
} label: {
4870
Text(authService.string.updatePasswordButtonLabel)
4971
.padding(.vertical, 8)
5072
.frame(maxWidth: .infinity)
5173
}
74+
.buttonStyle(.borderedProminent)
5275
.padding([.top, .bottom], 8)
5376
.frame(maxWidth: .infinity)
54-
.buttonStyle(.borderedProminent)
55-
Button(action: {
77+
.accessibilityIdentifier("update-password-button")
78+
79+
Button {
5680
authService.navigator.push(.mfaManagement)
57-
}) {
81+
} label: {
5882
Text("Manage Two-Factor Authentication")
5983
.padding(.vertical, 8)
6084
.frame(maxWidth: .infinity)
6185
}
86+
.buttonStyle(.borderedProminent)
6287
.padding([.top, .bottom], 8)
6388
.frame(maxWidth: .infinity)
64-
.buttonStyle(.borderedProminent)
6589
.accessibilityIdentifier("mfa-management-button")
66-
Button(action: {
90+
91+
Button {
6792
showDeleteConfirmation = true
68-
}) {
93+
} label: {
6994
Text(authService.string.deleteAccountButtonLabel)
7095
.padding(.vertical, 8)
7196
.frame(maxWidth: .infinity)
7297
}
98+
.buttonStyle(.borderedProminent)
7399
.padding([.top, .bottom], 8)
74100
.frame(maxWidth: .infinity)
75-
.buttonStyle(.borderedProminent)
76101
.accessibilityIdentifier("delete-account-button")
77-
Button(action: {
102+
103+
Button {
78104
Task {
79105
try? await authService.signOut()
80106
}
81-
}) {
107+
} label: {
82108
Text(authService.string.signOutButtonLabel)
83109
.padding(.vertical, 8)
84110
.frame(maxWidth: .infinity)
85111
}
112+
.buttonStyle(.borderedProminent)
86113
.padding([.top, .bottom], 8)
87114
.frame(maxWidth: .infinity)
88-
.buttonStyle(.borderedProminent)
89115
.accessibilityIdentifier("sign-out-button")
90116
}
91117
.safeAreaPadding()
@@ -106,6 +132,25 @@ extension SignedInView: View {
106132
.sheet(isPresented: isShowingPasswordPrompt) {
107133
PasswordPromptSheet(coordinator: authService.passwordPrompt)
108134
}
135+
.sheet(isPresented: $showEmailVerificationSent) {
136+
VStack(spacing: 24) {
137+
Text(authService.string.verifyEmailSheetMessage)
138+
.font(.headline)
139+
Button {
140+
showEmailVerificationSent = false
141+
} label: {
142+
Text(authService.string.okButtonLabel)
143+
.padding(.vertical, 8)
144+
.frame(maxWidth: .infinity)
145+
}
146+
.buttonStyle(.borderedProminent)
147+
.padding([.top, .bottom], 8)
148+
.frame(maxWidth: .infinity)
149+
}
150+
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
151+
.safeAreaPadding()
152+
.presentationDetents([.medium])
153+
}
109154
}
110155
}
111156

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/VerifyEmailView.swift

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)