diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/EmailInput.kt b/library/src/main/java/com/telefonica/mistica/compose/input/EmailInput.kt index 80f3b5287..8fae53e01 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/EmailInput.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/EmailInput.kt @@ -10,7 +10,7 @@ fun EmailInput( modifier: Modifier, value: String, onValueChange: (String) -> Unit, - label: String, + label: String?, helperText: String? = null, isError: Boolean = false, errorText: String? = null, diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/NumberInput.kt b/library/src/main/java/com/telefonica/mistica/compose/input/NumberInput.kt index d3e07d692..24af57ce6 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/NumberInput.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/NumberInput.kt @@ -11,7 +11,7 @@ fun NumberInput( modifier: Modifier, value: String, onValueChange: (String) -> Unit, - label: String, + label: String?, helperText: String? = null, isError: Boolean = false, errorText: String? = null, diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/PasswordInput.kt b/library/src/main/java/com/telefonica/mistica/compose/input/PasswordInput.kt index f419f483a..a0bc0ccee 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/PasswordInput.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/PasswordInput.kt @@ -20,7 +20,7 @@ import com.telefonica.mistica.R fun PasswordInput( value: String, onValueChange: (String) -> Unit, - label: String, + label: String?, modifier: Modifier = Modifier, helperText: String? = null, isError: Boolean = false, diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/PhoneInput.kt b/library/src/main/java/com/telefonica/mistica/compose/input/PhoneInput.kt index f1131f88f..7af509d6a 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/PhoneInput.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/PhoneInput.kt @@ -10,7 +10,7 @@ fun PhoneInput( modifier: Modifier, value: String, onValueChange: (String) -> Unit, - label: String, + label: String?, helperText: String? = null, isError: Boolean = false, errorText: String? = null, diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt b/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt index 13755486f..8219b7463 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/TextAreaInput.kt @@ -15,7 +15,7 @@ import androidx.compose.ui.tooling.preview.Preview fun TextAreaInput( value: String, onValueChange: (String) -> Unit, - label: String, + label: String?, modifier: Modifier = Modifier, helperText: String? = null, isError: Boolean = false, diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/TextInput.kt b/library/src/main/java/com/telefonica/mistica/compose/input/TextInput.kt index 2f13fff69..38126f19b 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/TextInput.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/TextInput.kt @@ -10,7 +10,7 @@ fun TextInput( modifier: Modifier, value: String, onValueChange: (String) -> Unit, - label: String, + label: String?, helperText: String? = null, isError: Boolean = false, errorText: String? = null, diff --git a/library/src/main/java/com/telefonica/mistica/compose/input/TextInputImpl.kt b/library/src/main/java/com/telefonica/mistica/compose/input/TextInputImpl.kt index be42e9d2c..d43c95ba3 100644 --- a/library/src/main/java/com/telefonica/mistica/compose/input/TextInputImpl.kt +++ b/library/src/main/java/com/telefonica/mistica/compose/input/TextInputImpl.kt @@ -29,7 +29,7 @@ internal fun TextInputImpl( modifier: Modifier = Modifier, value: String, onValueChange: (String) -> Unit, - label: String, + label: String?, helperText: String?, isError: Boolean, errorText: String?, @@ -82,7 +82,7 @@ private fun TextBox( value: String, modifier: Modifier = Modifier, onValueChange: (String) -> Unit, - label: String, + label: String?, isError: Boolean, trailingIcon: @Composable (() -> Unit)?, enabled: Boolean, @@ -113,16 +113,18 @@ private fun TextBox( readOnly = readOnly, value = value, onValueChange = onValueChange, - label = { - val transformedText = remember(value) { - visualTransformation.filter(AnnotatedString(value)) + label = label?.let { + { + val transformedText = remember(value) { + visualTransformation.filter(AnnotatedString(value)) + } + TextInputLabel( + text = it, + inputIsNotEmpty = transformedText.text.isNotEmpty(), + isFocused = interactionSource.collectIsFocusedAsState().value, + isError = isError, + ) } - TextInputLabel( - text = label, - inputIsNotEmpty = transformedText.text.isNotEmpty(), - isFocused = interactionSource.collectIsFocusedAsState().value, - isError = isError, - ) }, interactionSource = interactionSource, keyboardOptions = keyboardOptions,