JengaOtpVerification

fun JengaOtpVerification(title: String, description: AnnotatedString, field: @Composable () -> Unit, modifier: Modifier = Modifier, verifying: Boolean = false, verifyingText: String? = null, header: @Composable () -> Unit? = null, resend: @Composable () -> Unit? = null, actions: @Composable ColumnScope.() -> Unit? = null, contentPadding: PaddingValues = JengaOtpVerificationDefaults.contentPadding, spacing: Dp = JengaOtpVerificationDefaults.spacing, titleStyle: TextStyle = JengaOtpVerificationDefaults.titleStyle, descriptionStyle: TextStyle = JengaOtpVerificationDefaults.descriptionStyle)(source)

A complete code-verification block: optional header, title, description, the code field, a "verifying" row, the resend row and actions, centered and spaced consistently.

It is plain content with no surface of its own, so the same block is used in a screen, a bottom sheet or a dialog.

Parameters

title

the heading, e.g. "Enter the code".

description

where the code was sent; style parts of it (such as the phone number) with an AnnotatedString.

field

the code input, normally a JengaOtpField.

modifier

the Modifier for the block.

verifying

whether the code is being checked; shows the verifying row.

verifyingText

the text next to the spinner while verifying, e.g. "Verifying…".

header

optional content above the title, such as an illustration.

resend

optional resend row, normally a JengaOtpResend.

actions

optional full-width actions at the bottom, such as a verify button.

contentPadding

padding around the block.

spacing

vertical space between sections.

titleStyle

the title text style.

descriptionStyle

the description text style.

Samples

var code by remember {
    mutableStateOf(
        value = "",
    )
}
val countdown = rememberJengaCountdown(
    duration = 5.minutes,
)
JengaOtpVerification(
    title = "Enter the code",
    description = AnnotatedString(
        text = "We sent a 6-digit code to +254 712 345 678",
    ),
    field = {
        JengaOtpField(
            value = code,
            onValueChange = { code = it },
            contentDescription = "Verification code",
        )
    },
    resend = {
        val remainingText = JengaOtpResendDefaults.formatRemaining(
            remaining = countdown.remaining,
        )
        JengaOtpResend(
            remaining = countdown.remaining,
            onResend = { countdown.restart() },
            countdownText = "Resend code in $remainingText",
            resendText = "Resend code",
        )
    },
)