@@ -36,6 +36,7 @@ import androidx.compose.ui.text.style.TextAlign
3636import androidx.compose.ui.unit.Dp
3737import androidx.compose.ui.unit.DpSize
3838import androidx.compose.ui.unit.dp
39+ import androidx.compose.ui.unit.max
3940import androidx.compose.ui.unit.sp
4041import top.yukonga.miuix.kmp.theme.MiuixTheme
4142import top.yukonga.miuix.kmp.utils.SmoothRoundedCornerShape
@@ -108,12 +109,14 @@ fun TextField(
108109 val isFocused by interactionSource.collectIsFocusedAsState()
109110 val borderWidth by animateDpAsState(if (isFocused) 2 .dp else 0 .dp)
110111 val borderColor by animateColorAsState(if (isFocused) borderColor else backgroundColor)
111- val labelOffsetY by animateDpAsState(if (value.text.isNotEmpty() && ! useLabelAsPlaceholder) - (insideMargin.height / 2 ) else 0 .dp)
112- val innerTextOffsetY by animateDpAsState(if (value.text.isNotEmpty() && ! useLabelAsPlaceholder) (insideMargin.height / 2 ) else 0 .dp)
113- val labelFontSize by animateDpAsState(if (value.text.isNotEmpty() && ! useLabelAsPlaceholder) 10 .dp else 17 .dp)
112+ val labelOffsetY by animateDpAsState(if (value.text.isNotEmpty() && ! useLabelAsPlaceholder) - (insideMargin.height / 2.2f ) else 0 .dp)
113+ val innerTextOffsetY by animateDpAsState(if (value.text.isNotEmpty() && ! useLabelAsPlaceholder) (insideMargin.height / 1.8f ) else 0 .dp)
114114 val border = Modifier .border(borderWidth, borderColor, RoundedCornerShape (cornerRadius))
115115 val labelOffset = if (label != " " && ! useLabelAsPlaceholder) Modifier .offset(y = labelOffsetY) else Modifier
116116 val innerTextOffset = if (label != " " && ! useLabelAsPlaceholder) Modifier .offset(y = innerTextOffsetY) else Modifier
117+ val labelFontSize by animateDpAsState(
118+ if (value.text.isNotEmpty() && ! useLabelAsPlaceholder) max(textStyle.fontSize.value.dp - 7 .dp, 0 .dp) else textStyle.fontSize.value.dp
119+ )
117120
118121 BasicTextField (
119122 value = value,
@@ -154,7 +157,7 @@ fun TextField(
154157 modifier = Modifier
155158 .weight(1f )
156159 .then(paddingModifier),
157- contentAlignment = Alignment .CenterStart
160+ contentAlignment = Alignment .TopStart
158161 ) {
159162 androidx.compose.animation.AnimatedVisibility (
160163 visible = if (useLabelAsPlaceholder) value.text.isEmpty() else true ,
0 commit comments