feat: rework comments page animations

This commit is contained in:
Harsh Shandilya
2026-06-06 10:32:21 +05:30
parent f8085a2962
commit a97616d722
25 changed files with 44 additions and 22 deletions
@@ -8,6 +8,8 @@ package dev.msfjarvis.claw.common.comments
import android.text.format.DateUtils
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.expandVertically
import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.background
@@ -225,7 +227,7 @@ internal fun CommentEntry(
start = 16.dp,
end = 16.dp,
top = 12.dp,
bottom = if (!isExpanded) 12.dp else 0.dp,
bottom = 12.dp,
),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalAlignment = Alignment.CenterVertically,
@@ -265,31 +267,51 @@ internal fun CommentEntry(
)
}
if (isExpanded) {
AnimatedVisibility(
visible = isExpanded,
enter =
expandVertically(
expandFrom = Alignment.Top,
animationSpec = tween(durationMillis = 100, easing = LinearEasing),
),
exit =
shrinkVertically(
shrinkTowards = Alignment.Top,
animationSpec = tween(durationMillis = 100, easing = LinearEasing),
),
) {
ThemedRichText(
text = comment.comment,
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 12.dp),
)
AnimatedVisibility(
visible = isActionBarExpanded,
enter = expandVertically(expandFrom = Alignment.Top),
exit = shrinkVertically(shrinkTowards = Alignment.Top),
) {
CommentActionTray(
isUpvoted = hasLocallyUpvoted,
onVoteClick = {
if (hasLocallyUpvoted) {
unvoteComment(comment.shortId)
} else {
upvoteComment(comment.shortId)
}
hasLocallyUpvoted = !hasLocallyUpvoted
},
onReplyClick = {
onReply(comment.shortId, plainTextFromHtml(comment.comment))
},
)
}
}
AnimatedVisibility(
visible = isActionBarExpanded,
enter =
expandVertically(
expandFrom = Alignment.Top,
animationSpec = tween(durationMillis = 50, easing = LinearEasing),
),
exit =
shrinkVertically(
shrinkTowards = Alignment.Top,
animationSpec = tween(durationMillis = 50, easing = LinearEasing),
),
) {
CommentActionTray(
isUpvoted = hasLocallyUpvoted,
onVoteClick = {
if (hasLocallyUpvoted) {
unvoteComment(comment.shortId)
} else {
upvoteComment(comment.shortId)
}
hasLocallyUpvoted = !hasLocallyUpvoted
},
onReplyClick = {
onReply(comment.shortId, plainTextFromHtml(comment.comment))
},
)
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 14 KiB