Last active
September 5, 2024 11:57
-
-
Save pflammertsma/fa6aa13c44365ceea872307cc8e92526 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
// Copyright 2024 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
@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