mirror of
https://github.com/BetterAndroid/FlexiUI.git
synced 2025-09-08 11:34:18 +08:00
style: optimize code
This commit is contained in:
@@ -222,6 +222,7 @@ private fun TextFieldDecorationBox(
|
|||||||
) {
|
) {
|
||||||
val focused by interactionSource.collectIsFocusedAsState()
|
val focused by interactionSource.collectIsFocusedAsState()
|
||||||
val hovered by interactionSource.collectIsHoveredAsState()
|
val hovered by interactionSource.collectIsHoveredAsState()
|
||||||
|
val animatedPlaceholder by animateFloatAsState(if (value.isNotEmpty()) 0f else 1f)
|
||||||
val animatedBorderColor by animateColorAsState(when {
|
val animatedBorderColor by animateColorAsState(when {
|
||||||
focused || hovered -> style.borderActive.solidColor
|
focused || hovered -> style.borderActive.solidColor
|
||||||
else -> style.borderInactive.solidColor
|
else -> style.borderInactive.solidColor
|
||||||
@@ -243,11 +244,10 @@ private fun TextFieldDecorationBox(
|
|||||||
interactionSource = interactionSource
|
interactionSource = interactionSource
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
val placeholderAlpha by animateFloatAsState(if (value.isNotEmpty()) 0f else 1f)
|
|
||||||
Row {
|
Row {
|
||||||
header()
|
header()
|
||||||
Box {
|
Box {
|
||||||
Box(modifier = Modifier.alpha(placeholderAlpha)) {
|
Box(modifier = Modifier.alpha(animatedPlaceholder)) {
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalTextStyle provides LocalTextStyle.current.default(LocalColors.current.textSecondary)
|
LocalTextStyle provides LocalTextStyle.current.default(LocalColors.current.textSecondary)
|
||||||
) { placeholder() }
|
) { placeholder() }
|
||||||
|
Reference in New Issue
Block a user