|
14 | 14 |
|
15 | 15 | package com.firebase.ui.auth.compose.mfa |
16 | 16 |
|
| 17 | +import com.firebase.ui.auth.compose.configuration.MfaFactor |
| 18 | +import com.firebase.ui.auth.compose.configuration.string_provider.AuthUIStringProvider |
| 19 | + |
17 | 20 | /** |
18 | 21 | * Represents the different steps in the Multi-Factor Authentication (MFA) enrollment flow. |
19 | 22 | * |
@@ -56,3 +59,40 @@ enum class MfaEnrollmentStep { |
56 | 59 | */ |
57 | 60 | ShowRecoveryCodes |
58 | 61 | } |
| 62 | + |
| 63 | +/** |
| 64 | + * Returns the localized title text for this enrollment step. |
| 65 | + * |
| 66 | + * @param stringProvider The string provider for localized strings |
| 67 | + * @return The localized title for this step |
| 68 | + */ |
| 69 | +fun MfaEnrollmentStep.getTitle(stringProvider: AuthUIStringProvider): String = when (this) { |
| 70 | + MfaEnrollmentStep.SelectFactor -> stringProvider.mfaStepSelectFactorTitle |
| 71 | + MfaEnrollmentStep.ConfigureSms -> stringProvider.mfaStepConfigureSmsTitle |
| 72 | + MfaEnrollmentStep.ConfigureTotp -> stringProvider.mfaStepConfigureTotpTitle |
| 73 | + MfaEnrollmentStep.VerifyFactor -> stringProvider.mfaStepVerifyFactorTitle |
| 74 | + MfaEnrollmentStep.ShowRecoveryCodes -> stringProvider.mfaStepShowRecoveryCodesTitle |
| 75 | +} |
| 76 | + |
| 77 | +/** |
| 78 | + * Returns localized helper text providing instructions for this step. |
| 79 | + * |
| 80 | + * @param stringProvider The string provider for localized strings |
| 81 | + * @param selectedFactor The MFA factor being configured or verified. Used for [MfaEnrollmentStep.VerifyFactor] |
| 82 | + * to provide factor-specific instructions. Ignored for other steps. |
| 83 | + * @return Localized instructional text appropriate for this step |
| 84 | + */ |
| 85 | +fun MfaEnrollmentStep.getHelperText( |
| 86 | + stringProvider: AuthUIStringProvider, |
| 87 | + selectedFactor: MfaFactor? = null |
| 88 | +): String = when (this) { |
| 89 | + MfaEnrollmentStep.SelectFactor -> stringProvider.mfaStepSelectFactorHelper |
| 90 | + MfaEnrollmentStep.ConfigureSms -> stringProvider.mfaStepConfigureSmsHelper |
| 91 | + MfaEnrollmentStep.ConfigureTotp -> stringProvider.mfaStepConfigureTotpHelper |
| 92 | + MfaEnrollmentStep.VerifyFactor -> when (selectedFactor) { |
| 93 | + MfaFactor.Sms -> stringProvider.mfaStepVerifyFactorSmsHelper |
| 94 | + MfaFactor.Totp -> stringProvider.mfaStepVerifyFactorTotpHelper |
| 95 | + null -> stringProvider.mfaStepVerifyFactorGenericHelper |
| 96 | + } |
| 97 | + MfaEnrollmentStep.ShowRecoveryCodes -> stringProvider.mfaStepShowRecoveryCodesHelper |
| 98 | +} |
0 commit comments