Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
Expand Up @@ -88,6 +88,9 @@ class MethodPickerTermsConfiguration(
* @param lastSignInPreference The last sign-in preference to show a "Continue as..." button.
* @param termsConfiguration Optional configuration for a custom ToS/Privacy Policy footer.
* When provided, replaces the default "By continuing..." text. See [MethodPickerTermsConfiguration].
* @param onContinueAsSelected A callback when the "Continue as..." button is selected, with the
* provider and saved identifier (email, phone number, etc.). Falls back to [onProviderSelected]
* if not provided.
Comment thread
just1and0 marked this conversation as resolved.
*
* @since 10.0.0
*/
Expand All @@ -102,7 +105,10 @@ fun AuthMethodPicker(
lastSignInPreference: SignInPreferenceManager.SignInPreference? = null,
customLayout: (@Composable (List<AuthProvider>, (AuthProvider) -> Unit) -> Unit)? = null,
termsConfiguration: MethodPickerTermsConfiguration? = null,
onContinueAsSelected: ((AuthProvider, String?) -> Unit)? = null,
) {
val continueAsHandler: (AuthProvider, String?) -> Unit =
onContinueAsSelected ?: { provider, _ -> onProviderSelected(provider) }
val context = LocalContext.current
val inPreview = LocalInspectionMode.current
val stringProvider = LocalAuthUIStringProvider.current
Expand Down Expand Up @@ -150,7 +156,7 @@ fun AuthMethodPicker(
provider = lastProvider,
identifier = preference.identifier,
enabled = providerButtonsEnabled,
onClick = { onProviderSelected(lastProvider) }
onClick = { continueAsHandler(lastProvider, preference.identifier) }
)
Spacer(modifier = Modifier.height(24.dp))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ fun FirebaseAuthScreen(
val pendingReauthState = remember { mutableStateOf<AuthState.ReauthenticationRequired?>(null) }
val pendingReauthOperation = remember { mutableStateOf<(suspend (android.content.Context) -> Unit)?>(null) }
val emailLinkFromDifferentDevice = remember { mutableStateOf<String?>(null) }
val prefillEmail = remember { mutableStateOf<String?>(null) }
val lastSignInPreference =
remember { mutableStateOf<SignInPreferenceManager.SignInPreference?>(null) }
val startRoute = remember(configuration.providers, configuration.isProviderChoiceAlwaysShown) {
Expand Down Expand Up @@ -231,7 +232,14 @@ fun FirebaseAuthScreen(
privacyPolicyUrl = configuration.privacyPolicyUrl,
lastSignInPreference = lastSignInPreference.value,
termsConfiguration = customMethodPickerTermsConfiguration,
onProviderSelected = onProviderSelected,
onProviderSelected = { provider ->
prefillEmail.value = null
onProviderSelected(provider)
},
onContinueAsSelected = { provider, identifier ->
prefillEmail.value = if (provider is AuthProvider.Email) identifier else null
onProviderSelected(provider)
},
)
}
}
Expand All @@ -242,6 +250,7 @@ fun FirebaseAuthScreen(
context = context,
configuration = configuration,
authUI = authUI,
prefillEmail = prefillEmail.value,
credentialForLinking = pendingLinkingCredential.value,
emailLinkFromDifferentDevice = emailLinkFromDifferentDevice.value,
onContinueWithProvider = continueWithProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fun EmailAuthScreen(
onSuccess: (AuthResult) -> Unit,
onError: (AuthException) -> Unit,
onCancel: () -> Unit,
prefillEmail: String? = null,
content: @Composable ((EmailAuthContentState) -> Unit)? = null,
) {
val provider = configuration.providers.filterIsInstance<AuthProvider.Email>().first()
Expand All @@ -150,7 +151,7 @@ fun EmailAuthScreen(
}
val mode = rememberSaveable { mutableStateOf(initialMode) }
val displayNameValue = rememberSaveable { mutableStateOf("") }
val emailTextValue = rememberSaveable { mutableStateOf("") }
val emailTextValue = rememberSaveable { mutableStateOf(prefillEmail ?: "") }
Comment thread
just1and0 marked this conversation as resolved.
val passwordTextValue = rememberSaveable { mutableStateOf("") }
val confirmPasswordTextValue = rememberSaveable { mutableStateOf("") }

Expand Down