Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Last active August 29, 2022 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skyyo/b1223cbee581a6f63f1193c4c00c66ca to your computer and use it in GitHub Desktop.
Save Skyyo/b1223cbee581a6f63f1193c4c00c66ca to your computer and use it in GitHub Desktop.
@Composable
fun VideosScreen(viewModel: VideosViewModel = hiltViewModel()) {
val listState = rememberLazyListState()
val playingItemIndex by viewModel.currentlyPlayingIndex.observeAsState()
var isCurrentItemVisible by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
snapshotFlow {
listState.visibleAreaContainsItem(playingItemIndex, videos)
}.collect { isItemVisible ->
isCurrentItemVisible = isItemVisible
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment