OutlinedEmailField

fun OutlinedEmailField(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 = OutlinedTextFieldDefaults.shape, colors: TextFieldColors = OutlinedTextFieldDefaults.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 OutlinedEmailField(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 = OutlinedTextFieldDefaults.shape, colors: TextFieldColors = OutlinedTextFieldDefaults.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

value

The current value of the email field.

onValueChange

The callback function for when the value of the email field changes.

validator

The form validator used to validate the email field value. Defaults to FormValidator.EMAIL.

modifier

The modifier for styling the email field. Defaults to Modifier.

label

The label for the email field. Defaults to null.

keyboardOptions

The keyboard options for the email field. Defaults to KeyboardOptions(keyboardType = KeyboardType.Email).

keyboardActions

The keyboard actions for the email field. Defaults to KeyboardActions.Default.

leadingIcon

The leading icon for the email field. Defaults to an email icon.

singleLine

Whether the email field should be a single line or multiline. Defaults to true.

enabled

Whether the email field should be enabled for user interaction. Defaults to true.

isError

Whether the email field should display an error state. Defaults to null (handled automatically).

interactionSource

The interaction source for the email field. Defaults to MutableInteractionSource.

textStyle

The text style for the email field. Defaults to LocalTextStyle.current.

shape

The shape of the email field. Defaults to TextFieldDefaults.shape.

colors

The colors for the email field. Defaults to TextFieldDefaults.colors().

supportingText

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.

trailingIcon

The trailing icon for the email field. Defaults to null.

placeholder

The placeholder for the email field. Defaults to null.

formKey

The key to store the validity of the email field in the AuthState. Defaults to "EMAIL".

mandatory

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.