Fixes the inconsistency of button animations in the reaction row

This commit is contained in:
Vitor Pamplona
2024-06-19 08:48:41 -04:00
parent 6c137a5174
commit e9456af15c
2 changed files with 35 additions and 16 deletions

View File

@@ -34,6 +34,7 @@ import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith import androidx.compose.animation.togetherWith
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
@@ -51,7 +52,6 @@ import androidx.compose.material.ripple.rememberRipple
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.IconButton
import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProgressIndicatorDefaults import androidx.compose.material3.ProgressIndicatorDefaults
@@ -215,7 +215,7 @@ fun ShareReaction(
) { ) {
val context = LocalContext.current val context = LocalContext.current
IconButton( ClickableBox(
modifier = barChartModifier, modifier = barChartModifier,
onClick = { onClick = {
val sendIntent = val sendIntent =
@@ -412,7 +412,7 @@ private fun RenderShowIndividualReactionsButton(
wantsToSeeReactions: MutableState<Boolean>, wantsToSeeReactions: MutableState<Boolean>,
accountViewModel: AccountViewModel, accountViewModel: AccountViewModel,
) { ) {
IconButton( ClickableBox(
onClick = { wantsToSeeReactions.value = !wantsToSeeReactions.value }, onClick = { wantsToSeeReactions.value = !wantsToSeeReactions.value },
modifier = Size20Modifier, modifier = Size20Modifier,
) { ) {
@@ -609,6 +609,24 @@ private fun ReplyReactionWithDialog(
ReplyReaction(baseNote, grayTint, accountViewModel) { wantsToReplyTo = baseNote } ReplyReaction(baseNote, grayTint, accountViewModel) { wantsToReplyTo = baseNote }
} }
@Composable
fun ClickableBox(
modifier: Modifier,
onClick: () -> Unit,
content: @Composable () -> Unit,
) {
Box(
modifier.clickable(
role = Role.Button,
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(bounded = false, radius = Size24dp),
onClick = onClick,
),
) {
content()
}
}
@Composable @Composable
fun ReplyReaction( fun ReplyReaction(
baseNote: Note, baseNote: Note,
@@ -618,7 +636,7 @@ fun ReplyReaction(
iconSizeModifier: Modifier = Size19Modifier, iconSizeModifier: Modifier = Size19Modifier,
onPress: () -> Unit, onPress: () -> Unit,
) { ) {
IconButton( ClickableBox(
modifier = iconSizeModifier, modifier = iconSizeModifier,
onClick = { onClick = {
if (baseNote.isDraft()) { if (baseNote.isDraft()) {
@@ -626,15 +644,15 @@ fun ReplyReaction(
R.string.draft_note, R.string.draft_note,
R.string.it_s_not_possible_to_reply_to_a_draft_note, R.string.it_s_not_possible_to_reply_to_a_draft_note,
) )
return@IconButton
}
if (accountViewModel.isWriteable()) {
onPress()
} else { } else {
accountViewModel.toast( if (accountViewModel.isWriteable()) {
R.string.read_only_user, onPress()
R.string.login_with_a_private_key_to_be_able_to_reply, } else {
) accountViewModel.toast(
R.string.read_only_user,
R.string.login_with_a_private_key_to_be_able_to_reply,
)
}
} }
}, },
) { ) {
@@ -747,9 +765,11 @@ fun BoostReaction(
) { ) {
var wantsToBoost by remember { mutableStateOf(false) } var wantsToBoost by remember { mutableStateOf(false) }
IconButton( ClickableBox(
modifier = iconSizeModifier, modifier = iconSizeModifier,
onClick = { accountViewModel.tryBoost(baseNote) { wantsToBoost = true } }, onClick = {
accountViewModel.tryBoost(baseNote) { wantsToBoost = true }
},
) { ) {
ObserveBoostIcon(baseNote, accountViewModel) { hasBoosted -> ObserveBoostIcon(baseNote, accountViewModel) { hasBoosted ->
RepostedIcon(iconSizeModifier, if (hasBoosted) Color.Unspecified else grayTint) RepostedIcon(iconSizeModifier, if (hasBoosted) Color.Unspecified else grayTint)

View File

@@ -27,7 +27,6 @@ import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ChevronRight import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@@ -88,7 +87,7 @@ fun ShouldShowExpandButton(
@Composable @Composable
fun ChatRelayExpandButton(onClick: () -> Unit) { fun ChatRelayExpandButton(onClick: () -> Unit) {
IconButton( ClickableBox(
modifier = Size15Modifier, modifier = Size15Modifier,
onClick = onClick, onClick = onClick,
) { ) {