feat: rework comments page animations
@@ -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))
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 14 KiB |