fun PasswordField(value: String, onValueChange: (String) -> Unit, rules: List<PasswordRule> = rememberPasswordRuleList(), modifier: Modifier = Modifier, visualTransformation: (showPassword: Boolean) -> VisualTransformation = { if(it) VisualTransformation.None else PasswordVisualTransformation() }, keyboardActions: KeyboardActions = KeyboardActions(), keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password), readOnly: Boolean = false, enabled: Boolean = true, singleLine: Boolean = true, isError: Boolean? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, textStyle: TextStyle = LocalTextStyle.current, shape: Shape = TextFieldDefaults.shape, colors: TextFieldColors = TextFieldDefaults.colors(), label: @Composable () -> Unit? = null, leadingIcon: @Composable () -> Unit? = { Icon(AuthIcons.rememberLockIcon(), "Lock") }, supportingText: @Composable (rules: List<PasswordRuleResult>) -> Unit? = {
if (value.isNotEmpty()) it.firstUnfulfilled()?.let { rule ->
Text(rule.description)
}
}, trailingIcon: @Composable (showPassword: MutableState<Boolean>) -> Unit? = { showPassword ->
IconButton(onClick = { showPassword.value = !showPassword.value }) {
Icon(if(showPassword.value) AuthIcons.rememberVisibilityIcon() else AuthIcons.rememberVisibilityOffIcon(), "Visibility")
}
}, placeholder: @Composable () -> Unit? = null, formKey: String = "PASSWORD", mandatory: Boolean = true)(source) fun PasswordField(value: TextFieldValue, onValueChange: (TextFieldValue) -> Unit, rules: List<PasswordRule> = rememberPasswordRuleList(), modifier: Modifier = Modifier, visualTransformation: (showPassword: Boolean) -> VisualTransformation = { if(it) VisualTransformation.None else PasswordVisualTransformation() }, keyboardActions: KeyboardActions = KeyboardActions(), keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password), readOnly: Boolean = false, enabled: Boolean = true, singleLine: Boolean = true, isError: Boolean? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, textStyle: TextStyle = LocalTextStyle.current, shape: Shape = TextFieldDefaults.shape, colors: TextFieldColors = TextFieldDefaults.colors(), label: @Composable () -> Unit? = null, leadingIcon: @Composable () -> Unit? = { Icon(AuthIcons.rememberLockIcon(), "Lock") }, supportingText: @Composable (rules: List<PasswordRuleResult>) -> Unit? = {
if (value.text.isNotEmpty()) it.firstUnfulfilled()?.let { rule ->
Text(rule.description)
}
}, trailingIcon: @Composable (showPassword: MutableState<Boolean>) -> Unit? = { showPassword ->
IconButton(onClick = { showPassword.value = !showPassword.value }) {
Icon(if(showPassword.value) AuthIcons.rememberVisibilityIcon() else AuthIcons.rememberVisibilityOffIcon(), "Visibility")
}
}, placeholder: @Composable () -> Unit? = null, formKey: String = "PASSWORD", mandatory: Boolean = true)(source) A custom password input field with custom rules and pre-defined styling.
Parameters
The current value of the password field.
The callback function for when the value of the password field changes.
The rules for the password field.
The modifier for styling the password field. Defaults to Modifier.
The label for the password field. Defaults to null.
The keyboard options for the password field. Defaults to KeyboardOptions(keyboardType = KeyboardType.Password).
The keyboard actions for the password field. Defaults to KeyboardActions.Default.
The leading icon for the password field. Defaults to an email icon.
Whether the password field should be a single line or multiline. Defaults to true.
Whether the password field should be enabled for user interaction. Defaults to true.
Whether the password field should display an error state. Defaults to null (handled automatically).
The interaction source for the password field. Defaults to MutableInteractionSource.
The text style for the password field. Defaults to LocalTextStyle.current.
The shape of the password field. Defaults to TextFieldDefaults.shape.
The colors for the password field. Defaults to TextFieldDefaults.colors().
A composable function to display supporting text based on the validity of the password field value. Defaults to displaying "Please enter a valid email address" if the value is not a valid email.
The trailing icon for the password field. Defaults to null.
The placeholder for the password field. Defaults to null.
The key to store the validity of the password field in the AuthState. Defaults to "EMAIL".
Whether the form field is mandatory or not. If false, will not affect the AuthState.validForm value. You can also make this value dynamic and only make the field mandatory, if e.g. the value is not empty. Default is true.