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