Skip to content

Commit

Permalink
ANDROID-15026 make TextInput label param as nullable (#374)
Browse files Browse the repository at this point in the history
* ANDROID-15026 make TextInput label param as nullable

* Remove number input for this PR

* Make label optional
  • Loading branch information
DevPabloGarcia authored Aug 1, 2024
1 parent 0134a51 commit 239facc
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 239facc

Please sign in to comment.