IdentificationTextField

fun IdentificationTextField(modifier: Modifier = Modifier, state: PCIFieldState, identificationType: IdentificationType?, onEvent: (IdentificationTextFieldEvent) -> Unit, enabled: Boolean = true, readOnly: Boolean = false, decorationBox: @Composable (innerTextField: @Composable () -> Unit) -> Unit = @Composable { innerTextField -> innerTextField() }, textStyle: TextStyle = MaterialTheme.typography.bodyLarge, keyboardOptions: KeyboardOptions? = null, keyboardActions: KeyboardActions = KeyboardActions.Default, cursorBrush: Brush = SolidColor(MaterialTheme.colorScheme.primary), visualTransformation: VisualTransformation = VisualTransformation.None)

A PCI-compliant identification input component for handling identification document numbers.

This component provides a secure input field for identification numbers (CPF, DNI, etc.), with automatic validation based on the selected identification type. It wraps the base PCITextField with identification-specific logic while maintaining all the security features.

The component integrates with PCIFieldState for secure input management and provides events through IdentificationTextFieldEvent for handling focus changes and value changes.

Features:

  • PCI-compliant input handling

  • Automatic max length validation based on identification type

  • Configurable keyboard type (numeric or alphanumeric) based on identification type

  • Real-time input state feedback

  • Customizable appearance and behavior

Example usage:

val state = rememberPCIFieldState()
val selectedType = IdentificationType(
id = "CPF",
name = "CPF",
type = "number",
minLength = 11,
maxLength = 11
)

IdentificationTextField(
state = state,
identificationType = selectedType,
onEvent = { event ->
when (event) {
is IdentificationTextFieldEvent.OnValueChanged -> {
// Handle value change
}
is IdentificationTextFieldEvent.OnFocusChanged -> {
// Handle focus change
}
}
},
textStyle = MaterialTheme.typography.bodyLarge
)

Parameters

modifier

Modifier to customize the style and behavior of the field

state

A PCIFieldState object that manages the secure input data

identificationType

The selected IdentificationType that defines validation rules

onEvent

Callback triggered for field events (focus changes, value changes)

enabled

Controls whether the field is interactive

readOnly

Controls whether the field is editable

decorationBox

Composable for adding decorative elements around the text field

textStyle

Text style applied to the input content

keyboardOptions

Configuration for the software keyboard (defaults based on identification type)

keyboardActions

Callbacks for keyboard action events

cursorBrush

Brush applied to customize the cursor appearance

visualTransformation

Visual transformations applied to the input text

See also