fix: Text field enlarge a little when focused

This commit is contained in:
Artem Chepurnoy 2024-03-30 09:28:17 +02:00
parent 50a0d6f591
commit b933993001
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
1 changed files with 7 additions and 5 deletions

View File

@ -393,7 +393,7 @@ fun FlatTextField(
)
val padding by animateDpAsState(
targetValue = if (focused) 28.dp else 0.dp,
targetValue = if (focused) 16.dp else 0.dp,
)
Box(
@ -401,13 +401,13 @@ fun FlatTextField(
.heightIn(min = 48.dp)
.graphicsLayer {
alpha = disabledAlphaState.value
translationY = -padding.value
},
contentAlignment = Alignment.CenterStart,
) {
Text(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = padding),
.fillMaxWidth(),
text = label,
fontSize = textSize.sp,
maxLines = 1,
@ -417,7 +417,7 @@ fun FlatTextField(
}
val focused = (hasFocus || value.text.isNotEmpty()) && label != null
val padding by animateDpAsState(
targetValue = if (focused) 20.dp else 0.dp,
targetValue = if (focused) 8.dp else 0.dp,
)
val finalPlaceholder = placeholder ?: value.hint
@ -427,7 +427,9 @@ fun FlatTextField(
.focusRequester2(fieldFocusRequester)
.heightIn(min = 48.dp),
boxModifier = boxModifier
.padding(top = padding),
.graphicsLayer {
translationY = padding.value
},
placeholder = if (finalPlaceholder != null) {
// composable
{