-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added animation when achievement images are clicked
- Loading branch information
Showing
6 changed files
with
135 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
...c/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementImage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
package io.github.droidkaigi.confsched2023.achievements.component | ||
|
||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.interaction.MutableInteractionSource | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.unit.dp | ||
import io.github.droidkaigi.confsched2023.model.Achievement | ||
import io.github.droidkaigi.confsched2023.model.AchievementAnimation | ||
|
||
@Composable | ||
fun AchievementImage( | ||
achievementAnimation: AchievementAnimation, | ||
modifier: Modifier = Modifier, | ||
showAnimation: (Achievement) -> Unit, | ||
) { | ||
val interactionSource = remember { MutableInteractionSource() } | ||
Image( | ||
painter = painterResource(id = achievementAnimation.getDrawableResId()), | ||
contentDescription = achievementAnimation.contentDescription, | ||
modifier = modifier | ||
.padding(horizontal = 21.dp), | ||
.padding(horizontal = 21.dp) | ||
.clickable( | ||
interactionSource = interactionSource, | ||
indication = null, | ||
) { | ||
showAnimation(achievementAnimation.achievement) | ||
}, | ||
) | ||
} |
28 changes: 28 additions & 0 deletions
28
.../java/io/github/droidkaigi/confsched2023/achievements/component/GetAchivementAnimation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.github.droidkaigi.confsched2023.achievements.component | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import com.airbnb.lottie.compose.LottieAnimation | ||
import com.airbnb.lottie.compose.LottieCompositionSpec.RawRes | ||
import com.airbnb.lottie.compose.animateLottieCompositionAsState | ||
import com.airbnb.lottie.compose.rememberLottieComposition | ||
|
||
@Composable | ||
fun GetAchievementAnimation( | ||
animationRawId: Int, | ||
onFinishAnimation: () -> Unit, | ||
) { | ||
val lottieComposition by rememberLottieComposition(RawRes(animationRawId)) | ||
val progress by animateLottieCompositionAsState( | ||
composition = lottieComposition, | ||
isPlaying = true, | ||
restartOnPlay = true, | ||
) | ||
if (progress == 1f) { | ||
onFinishAnimation() | ||
} | ||
LottieAnimation( | ||
composition = lottieComposition, | ||
progress = { progress }, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters