Skip to content

Instantly share code, notes, and snippets.

@dilrajsingh1997
Created May 31, 2022 10:36
Show Gist options
  • Save dilrajsingh1997/a919699f6aeccebc2ead69d63628f5e3 to your computer and use it in GitHub Desktop.
Save dilrajsingh1997/a919699f6aeccebc2ead69d63628f5e3 to your computer and use it in GitHub Desktop.
val producerChannel = remember {
Channel<List<ItemState>>(Channel.UNLIMITED)
}
LaunchedEffect(true) {
for (incomingList in producerChannel) {
launch(Dispatchers.IO) {
itemsToAnimate.trySend(hearts.value.toMutableList().apply {
addAll(incomingList)
})
}
}
}
Button(
onClick = {
producerChannel.trySend(List(1) {
ItemState(
x = Random.nextInt(0, (width).toInt()).toFloat(),
y = height,
yAnimation = TargetBasedAnimation(
animationSpec = tween(durationMillis = 5500, easing = FastOutSlowInEasing),
typeConverter = Float.VectorConverter,
initialValue = height,
targetValue = height / 2
)
)
}
)
},
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(24.dp)
.wrapContentHeight()
.wrapContentWidth()
) {
Text(
text = "Like",
color = Color.White
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment