Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import FirebaseAuthUIComponents
import SwiftUI

/// The stock content of ``EmailLinkReauthScreen``.
@MainActor
public struct DefaultEmailLinkReauthContent: View {
public init(state: EmailLinkReauthContentState) {
self.state = state
}

private let state: EmailLinkReauthContentState

public var body: some View {
VStack(spacing: 24) {
if state.linkSent {
// "Check your email" state
VStack(spacing: 16) {
Image(systemName: "envelope.open.fill")
.font(.system(size: 60))
.foregroundColor(.accentColor)
.padding(.top, 32)
Comment on lines +32 to +35

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use .foregroundStyle instead of the deprecated .foregroundColor modifier. In modern SwiftUI (iOS 15+), .foregroundStyle is preferred for setting the color or style of views, and .foregroundStyle(.tint) is the idiomatic way to apply the accent color.

Suggested change
Image(systemName: "envelope.open.fill")
.font(.system(size: 60))
.foregroundColor(.accentColor)
.padding(.top, 32)
Image(systemName: "envelope.open.fill")
.font(.system(size: 60))
.foregroundStyle(.tint)
.padding(.top, 32)


Text("Check Your Email")
.authFont(.title)
.fontWeight(.bold)

Text("We've sent a verification link to:")
.authFont(.body)
.foregroundStyle(.secondary)

Text(state.email)
.authFont(.body)
.fontWeight(.medium)
.padding(.horizontal)

Text("Tap the link in the email to complete reauthentication.")
.authFont(.body)
.multilineTextAlignment(.center)
.foregroundStyle(.secondary)
.padding(.horizontal, 32)
.padding(.top, 8)

Button(action: state.resendLink) {
if state.isLoading {
ProgressView()
.frame(height: 32)
} else {
Text("Resend Email")
.authCustomFont(.body)
.frame(height: 32)
}
}
.buttonStyle(.bordered)
.disabled(state.isLoading)
.padding(.top, 16)
}
} else {
// Loading/sending state
VStack(spacing: 16) {
ProgressView()
.padding(.top, 32)
Text("Sending verification email...")
.authCustomFont(.body)
.foregroundStyle(.secondary)
}
}

Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.navigationTitle("Verify Your Identity")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel", action: state.cancel)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import FirebaseAuthUIComponents
import SwiftUI

/// The stock content of ``EmailReauthScreen``.
@MainActor
public struct DefaultEmailReauthContent: View {
public init(state: EmailReauthContentState) {
self.state = state
}

@Environment(AuthService.self) private var authService
private let state: EmailReauthContentState

public var body: some View {
VStack(spacing: 24) {
// Header
VStack(spacing: 12) {
Image(systemName: "lock.circle.fill")
.font(.system(size: 60))
.foregroundColor(.blue)
Comment on lines +32 to +34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use .foregroundStyle instead of the deprecated .foregroundColor modifier.

Suggested change
Image(systemName: "lock.circle.fill")
.font(.system(size: 60))
.foregroundColor(.blue)
Image(systemName: "lock.circle.fill")
.font(.system(size: 60))
.foregroundStyle(.blue)


Text(authService.string.confirmPasswordTitle)
.authFont(.title)
.fontWeight(.bold)

Text(authService.string.forSecurityEnterPasswordMessage)
.authFont(.body)
.foregroundColor(.secondary)
Comment on lines +40 to +42

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use .foregroundStyle instead of the deprecated .foregroundColor modifier.

Suggested change
Text(authService.string.forSecurityEnterPasswordMessage)
.font(.body)
.foregroundColor(.secondary)
Text(authService.string.forSecurityEnterPasswordMessage)
.font(.body)
.foregroundStyle(.secondary)

.multilineTextAlignment(.center)
}
.padding()

VStack(spacing: 20) {
Text(authService.string.emailPrefix(email: state.email))
.authFont(.caption)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.bottom, 8)

AuthTextField(
text: state.password,
label: authService.string.passwordFieldLabel,
prompt: authService.string.passwordInputLabel,
contentType: .password,
isSecureTextField: true,
onSubmit: { _ in
state.verify()
},
leading: {
Image(systemName: "lock")
}
)
.submitLabel(.done)
.accessibilityIdentifier("email-reauth-password-field")

Button(action: state.verify) {
if state.isLoading {
ProgressView()
.frame(height: 32)
.frame(maxWidth: .infinity)
} else {
Text(authService.string.confirmButtonLabel)
.frame(height: 32)
.frame(maxWidth: .infinity)
}
}
.authCTAButtonStyle()
.disabled(!state.isValid || state.isLoading)
.accessibilityIdentifier("confirm-password-button")

Button(authService.string.cancelButtonLabel, action: state.cancel)
}
.padding(.horizontal)

Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.navigationBarTitleDisplayMode(.inline)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import FirebaseAuthUIComponents
import SwiftUI

/// The stock content of ``PhoneReauthScreen``.
@MainActor
public struct DefaultPhoneReauthContent: View {
public init(state: PhoneReauthContentState) {
self.state = state
}

@Environment(AuthService.self) private var authService
private let state: PhoneReauthContentState

public var body: some View {
VStack(spacing: 24) {
// Header
VStack(spacing: 12) {
Image(systemName: "phone.circle.fill")
.font(.system(size: 60))
.foregroundColor(.blue)
Comment on lines +32 to +34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use .foregroundStyle instead of the deprecated .foregroundColor modifier.

Suggested change
Image(systemName: "phone.circle.fill")
.font(.system(size: 60))
.foregroundColor(.blue)
Image(systemName: "phone.circle.fill")
.font(.system(size: 60))
.foregroundStyle(.blue)


Text(authService.string.verifyPhoneNumberTitle)
.authFont(.title)
.fontWeight(.bold)

Text(authService.string.forSecurityVerifyPhoneMessage)
.authFont(.body)
.foregroundColor(.secondary)
Comment on lines +40 to +42

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use .foregroundStyle instead of the deprecated .foregroundColor modifier.

Suggested change
Text(authService.string.forSecurityVerifyPhoneMessage)
.font(.body)
.foregroundColor(.secondary)
Text(authService.string.forSecurityVerifyPhoneMessage)
.font(.body)
.foregroundStyle(.secondary)

.multilineTextAlignment(.center)
}
.padding()

if !state.codeSent {
// Initial state - sending SMS
VStack(spacing: 20) {
Text(authService.string.sendVerificationCodeToPhonePrefix)
.authFont(.subheadline)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)

Text(state.phoneNumber)
.authFont(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.bottom, 8)

Button(action: state.sendCode) {
if state.isLoading {
ProgressView()
.frame(height: 32)
.frame(maxWidth: .infinity)
} else {
Text(authService.string.sendVerificationCodeButtonLabel)
.frame(height: 32)
.frame(maxWidth: .infinity)
}
}
.authCTAButtonStyle()
.disabled(state.isLoading)
.accessibilityIdentifier("send-verification-code-button")
Button(authService.string.cancelButtonLabel, action: state.cancel)
}
.padding(.horizontal)
} else {
// Enter verification code
VStack(spacing: 20) {
Text(authService.string.enterSixDigitCodeSentToPrefix)
.authFont(.subheadline)
.foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)

Text(state.phoneNumber)
.authFont(.caption)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.bottom, 8)

VerificationCodeInputField(
code: state.verificationCode,
validations: [
FormValidators.verificationCode,
],
maintainsValidationMessage: true
)
.accessibilityIdentifier("verification-code-field")

Button(action: state.verify) {
if state.isLoading {
ProgressView()
.frame(height: 32)
.frame(maxWidth: .infinity)
} else {
Text(authService.string.verifyButtonLabel)
.frame(height: 32)
.frame(maxWidth: .infinity)
}
}
.authCTAButtonStyle()
.disabled(!state.isValid || state.isLoading)
.accessibilityIdentifier("verify-button")

Button(action: state.sendCode) {
Text("Resend Code")
.frame(height: 32)
.frame(maxWidth: .infinity)
}
.buttonStyle(.bordered)
.disabled(state.isLoading)
.accessibilityIdentifier("resend-code-button")

Button(authService.string.cancelButtonLabel, action: state.cancel)
}
.padding(.horizontal)
}

Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.navigationBarTitleDisplayMode(.inline)
}
}
Loading
Loading