Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
fb0634d
Adjust EmailAuthView label font weights and drop hardcoded blue tint …
demolaf Jul 6, 2026
dba5839
Add AuthTextFieldStyle and AuthCTAButtonStyle for environment-driven …
demolaf Jul 6, 2026
4526060
Add AuthTypography for environment-driven custom font family, and clo…
demolaf Jul 7, 2026
3df3802
fix(auth): apply AuthTypography to typed text and the authenticating …
demolaf Sep 25, 2026
a552c15
feat(auth): re-export FirebaseAuthUIComponents from FirebaseAuthSwiftUI
demolaf Sep 25, 2026
da943d3
fix(auth): avoid double Dynamic Type scaling for custom font families
demolaf Sep 25, 2026
840a755
fix(auth): address review findings on theming defaults and API surface
demolaf Sep 25, 2026
9cea986
fix(auth): apply AuthTextFieldStyle to the verification code input
demolaf Sep 25, 2026
523dbdc
fix(auth): leave inherited font, shape and tint alone when no theme i…
demolaf Oct 22, 2026
df93299
feat(auth): add pickerContent and pickerDestination slots to AuthPick…
demolaf Sep 29, 2026
1f9a66e
fix(auth): keep signed-in and progress UI outside the pickerContent slot
demolaf Sep 29, 2026
a6caa62
docs(auth): add usage examples to AuthPickerView and authFont
demolaf Oct 20, 2026
f0fa077
fix(auth): let the authenticating overlay inherit the app font when n…
demolaf Oct 22, 2026
df2c4fc
feat(auth): support custom method picker layouts in DefaultAuthPicker…
demolaf Oct 20, 2026
c72d599
refactor(auth): simplify provider selection and default method picker
demolaf Oct 21, 2026
74397c0
feat(auth): pass AuthMethodPickerState to a whole-screen pickerContent
demolaf Oct 22, 2026
6816cd1
fix(auth): hide the picker title for a whole-screen pickerContent and…
demolaf Oct 22, 2026
9ed03af
test(auth): cover AuthMethodPickerState routing to the MFA, conflict …
demolaf Oct 22, 2026
02bb2b0
feat(auth): add content slots to phone number and verification code s…
demolaf Oct 20, 2026
8070ba5
fix(auth): tighten phone screen actions and match the picker state API
demolaf Oct 20, 2026
ba7ecda
fix(auth): let the resend code button inherit the app font when no th…
demolaf Oct 22, 2026
46e54a0
feat(auth): add content slots to email sign-in screens
demolaf Oct 21, 2026
b28b50a
fix(auth): address review of the email content slots
demolaf Oct 21, 2026
cf0ffbe
docs(auth): point email screen docs at the whole-screen pickerContent
demolaf Oct 22, 2026
4efe16c
feat(auth): add content slot to MFA enrolment screen
demolaf Oct 21, 2026
67cc632
fix(auth): tighten MFA enrolment steps and factor validation
demolaf Oct 21, 2026
bce0016
fix(auth): return expired MFA enrolment sessions to factor selection
demolaf Oct 21, 2026
bdc298d
test(auth): cover MFA enrolment action guards
demolaf Oct 21, 2026
513cd6d
feat(auth): add content slots to MFA resolution and management screens
demolaf Oct 21, 2026
6bd36dc
fix(auth): attach MFA screen modifiers once and tighten their state
demolaf Oct 21, 2026
d9f07ca
feat(auth): add signedInContent slot to AuthPickerView
demolaf Oct 21, 2026
33c13ae
Merge remote-tracking branch 'origin/auth/mfa-enrolment-content-slot'…
demolaf Oct 22, 2026
99f8f36
Merge remote-tracking branch 'origin/auth/mfa-content-slots' into sam…
demolaf Oct 22, 2026
136d366
Merge remote-tracking branch 'origin/auth/signed-in-content' into sam…
demolaf Oct 22, 2026
074f290
feat(sample): add full-customization example covering every auth screen
demolaf Oct 22, 2026
995a908
fix(sample): address fresh-eyes review of the full-customization example
demolaf Oct 22, 2026
c9b83ae
fix(sample): size the full-customization form to the Figma width
demolaf Oct 22, 2026
d507f15
fix(sample): draw the full-customization background as its own layer
demolaf Oct 22, 2026
cfd695e
fix(sample): even out the full-customization sign-in method spacing
demolaf Oct 22, 2026
165ab3a
fix(sample): show stock provider buttons in the more sign-in options …
demolaf Oct 22, 2026
973d593
fix(sample): move the sign-in / sign-up switch under the email form
demolaf Oct 22, 2026
2b376f0
fix(sample): even the spacing around the sign-in / sign-up switch
demolaf Oct 22, 2026
0c36923
feat(sample): preview the full-customization TOTP setup step
demolaf Oct 22, 2026
edd4d3b
fix(sample): inset full-customization screens 32 points
demolaf Oct 22, 2026
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
17 changes: 17 additions & 0 deletions FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Exports.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.

// FirebaseAuthUIComponents is not a library product, so re-export it to make
// AuthTextFieldStyle and AuthTypography reachable from `import FirebaseAuthSwiftUI`.
@_exported import FirebaseAuthUIComponents
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public protocol AuthProviderUI {
var provider: AuthProviderSwift { get }
}

/// Lets ``AuthService/triggerSignIn(for:)`` start sign-in for a provider whose flow doesn't
/// produce a credential, such as phone or a custom flow that presents its own screens.
///
/// Adopt it on a custom provider so a custom method picker layout can start its sign-in through
/// ``AuthMethodPickerState/select``. Otherwise, start sign-in from the provider's own button.
///
/// Example:
/// ```swift
/// extension MyProviderAuthUI: AuthProviderAction {
/// func triggerAction() async throws {
/// try await startMySignInFlow()
/// }
/// }
/// ```
public protocol AuthProviderAction: AuthProviderUI {
@MainActor func triggerAction() async throws
}

public enum AuthenticationState {
case unauthenticated
case authenticating
Expand Down Expand Up @@ -184,6 +202,40 @@ public final class AuthService {
providers.append(providerWithButton)
}

/// The providers registered with ``registerProvider(providerWithButton:)``, in registration
/// order. Email and email-link sign-in aren't included.
public var registeredProviders: [AuthProviderUI] {
providers
}

/// Starts sign-in with `provider` without rendering its button.
///
/// ``AuthProviderAction`` providers run ``AuthProviderAction/triggerAction()``, in which case
/// this returns `nil`. Other credential-based providers sign in through ``signIn(_:)``.
/// Any other provider throws ``AuthServiceError/providerAuthenticationFailed(_:)``.
public func triggerSignIn(for provider: AuthProviderUI) async throws -> SignInOutcome? {
if let actionProvider = provider as? AuthProviderAction {
try await actionProvider.triggerAction()
return nil
}
if let credentialProvider = provider.provider as? CredentialAuthProviderSwift {
return try await signIn(credentialProvider)
}
throw AuthServiceError.providerAuthenticationFailed(
"\(provider.displayName) doesn't support starting sign-in programmatically. " +
"Adopt AuthProviderAction on the provider, or start sign-in from its own button."
)
}

/// Runs the email-link sign-in action, the same as the stock email-link button.
func selectEmailLink() {
if let callback = emailLinkSignInCallback {
callback()
} else {
navigator.push(.emailLink)
}
}

public func renderButtons(spacing: CGFloat = 16) -> AnyView {
AnyView(
VStack(spacing: spacing) {
Expand All @@ -193,11 +245,7 @@ public final class AuthService {
style: .email,
accessibilityId: "sign-in-with-email-link-button"
) {
if let callback = self.emailLinkSignInCallback {
callback()
} else {
self.navigator.push(.emailLink)
}
self.selectEmailLink()
}
}
ForEach(providers, id: \.id) { provider in
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// 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

/// Styling configuration for the primary call-to-action buttons used throughout the auth flow
/// (sign in, send code, update password, etc). All fields default to `nil`, in which case
/// today's exact appearance is unchanged — including `backgroundColor`, which otherwise already
/// follows the environment's `.tint()` via `.buttonStyle(.borderedProminent)`; setting it here
/// overrides that for CTA buttons specifically, without affecting `.tint()` elsewhere.
public struct AuthCTAButtonStyle: Sendable {
public var backgroundColor: Color?
public var contentColor: Color?
public var shape: ButtonBorderShape?
public var font: Font?

public init(backgroundColor: Color? = nil,
contentColor: Color? = nil,
shape: ButtonBorderShape? = nil,
font: Font? = nil) {
self.backgroundColor = backgroundColor
self.contentColor = contentColor
self.shape = shape
self.font = font
}

public static let `default` = AuthCTAButtonStyle()
}

private struct AuthCTAButtonStyleKey: EnvironmentKey {
static let defaultValue: AuthCTAButtonStyle = .default
}

public extension EnvironmentValues {
var authCTAButtonStyle: AuthCTAButtonStyle {
get { self[AuthCTAButtonStyleKey.self] }
set { self[AuthCTAButtonStyleKey.self] = newValue }
}
}

/// Applies `.buttonStyle(.borderedProminent)` plus the colors/shape/font from the environment's
/// ``AuthCTAButtonStyle``, in place of a bare `.buttonStyle(.borderedProminent)` call. Unset
/// values leave the inherited shape, tint and font alone. When `style.font` is unset, the label
/// uses ``AuthTypography``'s custom font if one is set.
struct AuthCTAButtonModifier: ViewModifier {
@Environment(\.authCTAButtonStyle) private var style

func body(content: Content) -> some View {
Group {
if let contentColor = style.contentColor {
content.foregroundStyle(contentColor)
} else {
content
}
}
.buttonStyle(.borderedProminent)
.modifier(CTAShapeModifier(shape: style.shape))
.modifier(CTATintModifier(tint: style.backgroundColor))
.modifier(CTAFontModifier(explicitFont: style.font))
}
}

// Each modifier below only applies a value when one is set, so an unset style leaves whatever
// the app set higher up (shape, tint, font) in effect, as before theming.

private struct CTAShapeModifier: ViewModifier {
let shape: ButtonBorderShape?

func body(content: Content) -> some View {
if let shape {
content.buttonBorderShape(shape)
} else {
content
}
}
}

private struct CTATintModifier: ViewModifier {
let tint: Color?

func body(content: Content) -> some View {
if let tint {
content.tint(tint)
} else {
content
}
}
}

private struct CTAFontModifier: ViewModifier {
let explicitFont: Font?

func body(content: Content) -> some View {
if let explicitFont {
content.font(explicitFont)
} else {
content.authCustomFont(.body)
}
}
}

extension View {
/// Applies the auth flow's primary call-to-action button styling, reading colors/shape/font
/// from the environment's ``AuthCTAButtonStyle`` (set via `.authCTAButtonStyle(_:)`).
func authCTAButtonStyle() -> some View {
modifier(AuthCTAButtonModifier())
}
}

public extension View {
/// Sets the ``AuthCTAButtonStyle`` used by every CTA button in this view's subtree.
///
/// ```swift
/// AuthPickerView { ... }
/// .authCTAButtonStyle(
/// AuthCTAButtonStyle(backgroundColor: theme.colors.tint, contentColor: .white, shape: .capsule)
/// )
/// ```
func authCTAButtonStyle(_ style: AuthCTAButtonStyle) -> some View {
environment(\.authCTAButtonStyle, style)
}
}
Loading