PinCollectorDialog

fun PinCollectorDialog(prompt: PinPrompt, onPinEntered: (String) -> Unit, onCancelled: () -> Unit)

A Jetpack Compose dialog for collecting an application PIN from the user.

This composable displays a Material Design 3 modal dialog that prompts the user to enter their application PIN. The dialog includes:

  • Configurable title, subtitle, and description text

  • A password input field with show/hide toggle

  • Cancel and Confirm action buttons

  • Full Material Theme integration

UI Components

Text Display

  • Title: Displayed in headlineSmall typography (optional, shown if not empty)

  • Subtitle: Displayed in bodyLarge typography (optional, shown if not empty)

  • Description: Displayed in bodyMedium typography (optional, shown if not empty)

PIN Input Field

  • Accepts numeric input via NumberPassword keyboard type

  • Obscures PIN by default using PasswordVisualTransformation

  • Includes a visibility toggle icon button to show/hide the PIN

  • Single-line input with Material 3 outlined text field styling

Action Buttons

  • Cancel: TextButton that dismisses the dialog without entering a PIN

  • Confirm: Primary Button that submits the entered PIN (disabled when PIN is empty)

Dialog Behavior

  • Dismissal: Can be dismissed by pressing the back button (triggers cancellation callback)

  • Click Outside: Clicking outside the dialog does NOT dismiss it (dismissOnClickOutside = false)

  • Confirmation: Clicking Confirm only works when a non-empty PIN is entered

This ensures the dialog adapts to light/dark themes and custom color schemes defined in the application.

Parameters

prompt

A PinPrompt object containing the title, subtitle, and description text to display in the dialog. Empty strings for any field will cause that component to not be displayed.

onPinEntered

Callback invoked when the user confirms their PIN entry. Receives the entered PIN as a String. The caller should convert this to a CharArray and clear it from memory after use for security.

onCancelled

Callback invoked when the user cancels the dialog by pressing Cancel, back button, or dismissing the dialog. No PIN is provided.

See also