ursus
10/14/2023, 5:10 PMAnimatedVisibility(
visible = value != null
) {
if (value != null) {
Text(value)
}
)
is this the correct way of using AnimatedVisibility
with Nullable
values?
feels a bit janky with the inner null check againvide
10/14/2023, 5:12 PMAnimatedContent
instead. It provides the state for the content lambda:
AnimatedContent(state = value) {
if (value != null) {
Text(value)
}
}
It uses AnimatedVisibility
internally.ursus
10/14/2023, 5:57 PMtransitionSpec { fadeIn() togerherWith fadeOut() }
but there is some sort of horizontal sliding going on
am I doing it wrong?vide
10/14/2023, 6:00 PMusing null
to the endursus
10/14/2023, 10:53 PMRow(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = fieldName,
style = MaterialTheme.typography.caption,
fontWeight = FontWeight.Medium
)
AnimatedContent(
targetState = error,
transitionSpec = { fadeIn() togetherWith fadeOut() },
label = ""
) {
if (it != null) {
Text(
text = it,
color = MaterialTheme.colors.onErrorBackground,
style = MaterialTheme.typography.caption,
maxLines = 1
)
}
}
}
as you can see there is this sliding & scaling effect as well, weirdtransitionSpec = { fadeIn(animationSpec = tween(1000)) togetherWith fadeOut(animationSpec = tween(1000)) }
i.e. just a longer duration, just to see it better, its the same speed as before, the slide scale is still there, same speed, but the concurrent fade is slower
looks like a bug to meCrossfade(targetState = error, label = "dwq") {
this works thought
even thought I didnt even know about it, as crossfade seems like just a specification of AnimatedContent/Visibility
transition, no?
Why hardcode a single transition that way, when there are endless of combinations..weird apiAlbert Chang
10/15/2023, 3:25 AMAnimatedVisibility
. Actually adding that will break the animation.vide
10/15/2023, 9:26 AMtransitionSpec = { fadeIn() togetherWith fadeOut() using null }