Skip to content

Instantly share code, notes, and snippets.

@pflammertsma
Last active July 4, 2024 08:23
Show Gist options
  • Save pflammertsma/fa6aa13c44365ceea872307cc8e92526 to your computer and use it in GitHub Desktop.
Save pflammertsma/fa6aa13c44365ceea872307cc8e92526 to your computer and use it in GitHub Desktop.
@Composable
fun SampleImmersiveList(movies: List<Movie>, modifier = Modifier) {
val selectedMovie = remember { mutableStateOf<Movie?>(movies.firstOrNull()) }
// Container
Box(
modifier = Modifier
.fillMaxWidth()
.height(400.dp)
) {
// Background
Box(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(20f / 7)
.background(selectedMovie.value?.background)
) {}
// Rows
LazyRow(
) {
items(movies) { movie ->
MyMovieCard(
modifier = Modifier
.onFocusChanged {
if (it.hasFocus) {
selectedMovie.value = movie
}
},
) {}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment