Fixed (?) rendering issue with calculated value text

Hard to catch this bug, may still be broken
This commit is contained in:
Sad Ellie 2022-11-20 20:32:05 +04:00
parent 7c38a60788
commit e0152b508e

View File

@ -23,8 +23,10 @@ import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.SizeTransform import androidx.compose.animation.SizeTransform
import androidx.compose.animation.expandHorizontally import androidx.compose.animation.expandHorizontally
import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.with import androidx.compose.animation.with
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource
@ -124,31 +126,32 @@ fun MyTextField(
} }
} }
LazyRow( AnimatedVisibility(
modifier = modifier visible = !secondaryText.isNullOrEmpty(),
.wrapContentHeight(), enter = expandVertically(),
reverseLayout = true, exit = shrinkVertically()
horizontalArrangement = Arrangement.End,
contentPadding = PaddingValues(horizontal = 8.dp)
) { ) {
item { LazyRow(
AnimatedVisibility(visible = !secondaryText.isNullOrEmpty()) { modifier = modifier
AnimatedContent(targetState = secondaryText, .wrapContentHeight(),
reverseLayout = true,
horizontalArrangement = Arrangement.End,
contentPadding = PaddingValues(horizontal = 8.dp)
) {
item {
AnimatedContent(
targetState = secondaryText,
transitionSpec = { transitionSpec = {
// Enter animation // Enter animation
(expandHorizontally( (expandHorizontally(clip = false, expandFrom = Alignment.Start) + fadeIn()
clip = false,
expandFrom = Alignment.Start
) + fadeIn()
// Exit animation // Exit animation
with fadeOut()) with fadeOut())
.using(SizeTransform(clip = false)) .using(SizeTransform(clip = false))
} }
) { ) {
Text( Text(
modifier = Modifier modifier = Modifier,
.fillMaxWidth(), text = Formatter.format(it ?: ""),
text = Formatter.format(secondaryText ?: ""),
textAlign = TextAlign.End, textAlign = TextAlign.End,
softWrap = false, softWrap = false,
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f), color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f),