Stefan Oltmann
12/21/2024, 3:46 PMStefan Oltmann
12/21/2024, 3:46 PM@Composable
fun AnimatedPhotoStack(
images: SnapshotStateList<ImageBitmap>
) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
images.forEachIndexed { index, image ->
val rotation = remember(image) { (-30..30).random().toFloat() }
val scale = remember(image) { Animatable(2f) }
// Animate properties when images list changes
LaunchedEffect(image) {
launch {
scale.animateTo(
targetValue = 0.5f,
animationSpec = tween(durationMillis = 2000)
)
}
}
Image(
bitmap = image,
contentDescription = null,
modifier = Modifier
.size(200.dp)
.rotate(rotation)
.graphicsLayer(
scaleX = scale.value,
scaleY = scale.value
)
.zIndex(index.toFloat())
)
}
}
}