fun OutlinedPhoneField(value: TextFieldValue, onValueChange: (TextFieldValue) -> Unit, validator: FormValidator = remember { FormValidator.PHONE }, mask: String? = DEFAULT_MASK, maskChar: Char = DEFAULT_MASK_CHAR, modifier: Modifier = Modifier, label: @Composable () -> Unit? = null, keyboardOptions: KeyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Phone
), keyboardActions: KeyboardActions = KeyboardActions.Default, leadingIcon: @Composable () -> Unit? = {
Icon(
imageVector = AuthIcons.rememberCallIcon(),
contentDescription = "Phone",
)
}, singleLine: Boolean = true, enabled: Boolean = true, isError: Boolean? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, textStyle: TextStyle = LocalTextStyle.current, shape: Shape = OutlinedTextFieldDefaults.shape, colors: TextFieldColors = OutlinedTextFieldDefaults.colors(), visualTransformation: VisualTransformation = mask?.let { PhoneVisualTransformation(it, maskChar) } ?: VisualTransformation.None, supportingText: @Composable (validPhone: Boolean) -> Unit? = { if(!it) Text("Please enter a valid phone number") }, trailingIcon: @Composable () -> Unit? = null, placeholder: @Composable () -> Unit? = null, formKey: String = "PHONE", mandatory: Boolean = true)(source) fun OutlinedPhoneField(value: String, onValueChange: (String) -> Unit, validator: FormValidator = remember { FormValidator.PHONE }, mask: String? = DEFAULT_MASK, maskChar: Char = DEFAULT_MASK_CHAR, modifier: Modifier = Modifier, label: @Composable () -> Unit? = null, keyboardOptions: KeyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Phone
), keyboardActions: KeyboardActions = KeyboardActions.Default, leadingIcon: @Composable () -> Unit? = {
Icon(
imageVector = AuthIcons.rememberCallIcon(),
contentDescription = "Phone",
)
}, singleLine: Boolean = true, enabled: Boolean = true, isError: Boolean? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, textStyle: TextStyle = LocalTextStyle.current, shape: Shape = OutlinedTextFieldDefaults.shape, colors: TextFieldColors = OutlinedTextFieldDefaults.colors(), visualTransformation: VisualTransformation = mask?.let { PhoneVisualTransformation(it, maskChar) } ?: VisualTransformation.None, supportingText: @Composable (validPhone: Boolean) -> Unit? = { if(!it) Text("Please enter a valid phone number") }, trailingIcon: @Composable () -> Unit? = null, placeholder: @Composable () -> Unit? = null, formKey: String = "PHONE", mandatory: Boolean = true)(source) A custom email input field with validation and pre-defined styling.
Parameters
The current value of the phone field.
The callback function for when the value of the phone field changes.
The mask for the phone field. This changes how the phone number gets displayed. The value will still be the raw number. Defaults to "+## ### #########".
The mask character for the phone field. Defaults to '#'.
The modifier for styling the phone field. Defaults to Modifier.
The label for the phone field. Defaults to null.
The keyboard options for the phone field. Defaults to KeyboardOptions(keyboardType = KeyboardType.Email).
The keyboard actions for the phone field. Defaults to KeyboardActions.Default.
The leading icon for the phone field. Defaults to an email icon.
Whether the phone field should be a single line or multiline. Defaults to true.
Whether the phone field should be enabled for user interaction. Defaults to true.
Whether the phone field should display an error state. Defaults to null (handled automatically).
The interaction source for the phone field. Defaults to MutableInteractionSource.
The text style for the phone field. Defaults to LocalTextStyle.current.
The shape of the phone field. Defaults to TextFieldDefaults.shape.
The colors for the phone field. Defaults to TextFieldDefaults.colors().
A composable function to display supporting text based on the validity of the phone field value. Defaults to displaying "Please enter a valid email address" if the value is not a valid email.
The trailing icon for the phone field. Defaults to null.
The placeholder for the phone field. Defaults to null.
The key to store the validity of the phone 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.