mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 01:36:42 +02:00
AnimatedVisibility seems faster than Crossfade
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.note
|
package com.vitorpamplona.amethyst.ui.note
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.Crossfade
|
import androidx.compose.animation.Crossfade
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@@ -358,6 +361,12 @@ private fun ParseAuthorCommentAndAmount(
|
|||||||
onReady(content)
|
onReady(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun click(content: MutableState<ZapAmountCommentNotification>, nav: (String) -> Unit) {
|
||||||
|
content.value.user?.let {
|
||||||
|
nav(routeFor(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun RenderState(
|
private fun RenderState(
|
||||||
content: MutableState<ZapAmountCommentNotification>,
|
content: MutableState<ZapAmountCommentNotification>,
|
||||||
@@ -366,11 +375,7 @@ private fun RenderState(
|
|||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.clickable {
|
modifier = Modifier.clickable { click(content, nav) },
|
||||||
content.value.user?.let {
|
|
||||||
nav(routeFor(it))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
DisplayAuthorCommentAndAmount(
|
DisplayAuthorCommentAndAmount(
|
||||||
@@ -418,8 +423,19 @@ fun CrossfadeToDisplayPicture(authorComment: MutableState<ZapAmountCommentNotifi
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CrossfadeToDisplayAmount(authorComment: MutableState<ZapAmountCommentNotification>) {
|
fun CrossfadeToDisplayAmount(authorComment: MutableState<ZapAmountCommentNotification>) {
|
||||||
Crossfade(authorComment.value, modifier = amountBoxModifier) {
|
val visible by remember(authorComment) {
|
||||||
it.amount?.let {
|
derivedStateOf {
|
||||||
|
authorComment.value.amount != null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = visible,
|
||||||
|
modifier = amountBoxModifier,
|
||||||
|
enter = fadeIn(),
|
||||||
|
exit = fadeOut()
|
||||||
|
) {
|
||||||
|
authorComment.value.amount?.let {
|
||||||
Box(
|
Box(
|
||||||
modifier = amountBoxModifier,
|
modifier = amountBoxModifier,
|
||||||
contentAlignment = Alignment.BottomCenter
|
contentAlignment = Alignment.BottomCenter
|
||||||
@@ -453,8 +469,18 @@ fun CrossfadeToDisplayComment(
|
|||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
accountViewModel: AccountViewModel
|
accountViewModel: AccountViewModel
|
||||||
) {
|
) {
|
||||||
Crossfade(authorComment.value) {
|
val visible by remember(authorComment) {
|
||||||
it.comment?.let {
|
derivedStateOf {
|
||||||
|
authorComment.value.comment != null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible,
|
||||||
|
enter = fadeIn(),
|
||||||
|
exit = fadeOut()
|
||||||
|
) {
|
||||||
|
authorComment.value.comment?.let {
|
||||||
TranslatableRichTextViewer(
|
TranslatableRichTextViewer(
|
||||||
content = it,
|
content = it,
|
||||||
canPreview = true,
|
canPreview = true,
|
||||||
|
Reference in New Issue
Block a user