Skip to content

feat(auth): support custom method picker layouts in DefaultAuthPickerContent - #1411

Open
demolaf wants to merge 2 commits into
auth/picker-slotsfrom
auth/method-picker-layout
Open

demolaf wants to merge 2 commits into
auth/picker-slotsfrom
auth/method-picker-layout

Conversation

@demolaf

@demolaf demolaf commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Adds DefaultAuthPickerContent(authMethodPicker:) so apps can lay out the provider buttons themselves, with the same MFA, account-conflict and error handling as the default buttons. Stacked on #1403.

Changes

  • The layout closure receives an AuthMethodPickerState: providers, select(_:), isEmailLinkEnabled and selectEmailLink(), so a custom layout can't silently drop email-link sign-in. Its public init lets apps preview layouts with stub actions.
  • AuthService gains registeredProviders and triggerSignIn(for:). The new opt-in AuthProviderAction covers providers with no credential and takes precedence when adopted; PhoneAuthProviderAuthUI adopts it.
  • select(_:) reports an error for a provider that is neither credential-based nor AuthProviderAction, instead of doing nothing.
  • The 14% horizontal inset moves into DefaultAuthMethodPicker, so custom layouts aren't padded. The default screen is pixel-identical to main.

API Usage

AuthPickerView { authenticatedApp }
  .pickerContent {
    DefaultAuthPickerContent { state in
      ForEach(state.providers, id: \.id) { provider in
        Button(provider.displayName) { state.select(provider) }
      }
      if state.isEmailLinkEnabled {
        Button("Email link", action: state.selectEmailLink)
      }
    }
  }

Maintainer note: Fixes internal CPRN-517

…Content

Add DefaultAuthPickerContent(authMethodPicker:), which hands the layout an AuthMethodPickerState with the registered providers, a select action that routes MFA, account conflicts and errors like the default buttons, and the email-link state and action.

Add AuthService.registeredProviders and triggerSignIn(for:), plus the opt-in AuthProviderAction protocol for providers whose sign-in yields no credential; PhoneAuthProviderAuthUI adopts it. Providers that support neither path report an error instead of doing nothing.

Move the 14% horizontal inset into DefaultAuthMethodPicker so custom layouts are not padded.
@demolaf
demolaf added this pull request to stack #1404 October 20, 2026 11:30
@demolaf demolaf changed the title auth/method picker layout feat(auth): support custom method picker layouts in DefaultAuthPickerContent Oct 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces the AuthProviderAction protocol and updates AuthService to support programmatic sign-in for custom providers. It also refactors DefaultAuthPickerContent to allow custom layouts for provider buttons via AuthMethodPickerState and adds comprehensive unit tests. The review feedback suggests improving code readability and efficiency by avoiding unidiomatic try await .success(...) syntax and removing redundant VStack wrappers in SwiftUI views.

Comment thread FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/DefaultAuthPickerContent.swift Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant