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) | |
}) |
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
Canvas(modifier = modifier, | |
onDraw = { | |
for (item in itemsToAnimate) { | |
translate(top = item.y, left = item.x) { | |
drawContext.canvas.nativeCanvas.apply { | |
drawPath( | |
path = getObjectPath(), | |
color = Color.Red | |
) | |
} |
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 itemsToAnimate = remember { | |
mutableStateOf<List<ItemState>>(mutableListOf()) | |
} | |
val itemsChannel = remember { | |
Channel<List<ItemState>>(Channel.UNLIMITED) | |
} | |
var job: Job? = remember { | |
null | |
} |
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 itemsToAnimate = remember { | |
mutableStateOf<List<ItemState>>(mutableListOf()) | |
} | |
val itemsChannel = remember { | |
Channel<List<ItemState>>(Channel.UNLIMITED) | |
} | |
var job: Job? = remember { | |
null | |
} |
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 height = with(LocalDensity.current) { | |
LocalConfiguration.current.screenHeightDp.dp.toPx() | |
} | |
val position = remember { | |
mutableStateOf(1) | |
} | |
val yOffset by animateFloatAsState( | |
targetValue = if (position.value == 0) { | |
height / 2 | |
} else { |
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 height = with(LocalDensity.current) { | |
LocalConfiguration.current.screenHeightDp.dp.toPx() | |
} | |
val position = remember { | |
mutableStateOf(1) | |
} | |
val yOffset by animateFloatAsState( | |
targetValue = if (position.value == 0) { | |
height / 2 | |
} else { |
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
@Composable | |
fun ProductsScreen( | |
viewModel: ProductsViewModel = hiltViewModel(), | |
) { | |
val lifecycle = LocalLifecycleOwner.current.lifecycle | |
val latestLifecycleEvent = remember { mutableStateOf(Lifecycle.Event.ON_ANY) } | |
DisposableEffect(lifecycle) { | |
val observer = LifecycleEventObserver { _, event -> | |
latestLifecycleEvent.value = event | |
} |
NewerOlder