Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
fun VideosScreen(viewModel: VideosViewModel = hiltViewModel()) {
val listState = rememberLazyListState()
val playingItemIndex by viewModel.currentlyPlayingIndex.observeAsState()
val isCurrentItemVisible = remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
snapshotFlow {
listState.visibleAreaContainsItem(playingItemIndex, videos)
}.collect { isItemVisible ->
isCurrentItemVisible.value = isItemVisible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment