Skip to content

Commit

Permalink
Merge pull request #978 from kosenda/feature/about-footer-links-icon-…
Browse files Browse the repository at this point in the history
…add-animation-scale

In AboutScreen, LinksIcon so that you know you are operating when you press it
  • Loading branch information
takahirom authored Sep 8, 2024
2 parents f6b08f4 + 3d999ba commit 86e8139
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package io.github.droidkaigi.confsched.about.component

import androidx.compose.animation.core.Animatable
import androidx.compose.foundation.Image
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction.Cancel
import androidx.compose.foundation.interaction.PressInteraction.Press
import androidx.compose.foundation.interaction.PressInteraction.Release
import androidx.compose.foundation.layout.size
import androidx.compose.material3.IconButton
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
Expand All @@ -23,9 +33,22 @@ fun AboutFooterLinksIcon(
modifier: Modifier = Modifier,
onClick: () -> Unit,
) {
val animationScale by remember { mutableStateOf(Animatable(1f)) }

val interactionSource = remember { MutableInteractionSource() }
LaunchedEffect(interactionSource) {
interactionSource.interactions.collect {
when (it) {
is Press -> animationScale.animateTo(targetValue = 0.9f)
is Release, is Cancel -> animationScale.animateTo(targetValue = 1.0f)
}
}
}

IconButton(
onClick = onClick,
modifier = modifier.testTag(testTag),
interactionSource = interactionSource,
modifier = modifier.testTag(testTag).scale(animationScale.value),
) {
Image(
painter = painter,
Expand Down

0 comments on commit 86e8139

Please sign in to comment.