Created
May 31, 2022 10:36
-
-
Save dilrajsingh1997/a919699f6aeccebc2ead69d63628f5e3 to your computer and use it in GitHub Desktop.
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
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