Skip to content

Instantly share code, notes, and snippets.

@Farhandroid
Created February 22, 2022 20:10
Show Gist options
  • Save Farhandroid/962fc5aa5fd766ebcbc7a574c073767d to your computer and use it in GitHub Desktop.
Save Farhandroid/962fc5aa5fd766ebcbc7a574c073767d to your computer and use it in GitHub Desktop.
MovieListContent
@Composable
fun MovieListContent(allMovies: List<Movie>, navController: NavHostController) {
LazyColumn(
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 4.dp)
) {
items(
items = allMovies,
itemContent = {
MovieListItem(movie = it, navController = navController)
}
)
}
}
@Composable
fun MovieListItem(movie: Movie, navController: NavHostController) {
Card(
modifier = Modifier
.padding(top = 8.dp)
.height(180.dp)
.fillMaxWidth(),
elevation = 4.dp,
backgroundColor = Color.DarkGray
) {
Row(
modifier = Modifier
.height(IntrinsicSize.Max)
.fillMaxWidth()
.clickable {
navController.navigate(route = Screen.MovieDetails.passMovieId(movie.movieId.toString()))
},
verticalAlignment = Alignment.CenterVertically
) {
Image(
modifier = Modifier
.padding(
end = 4.dp,
)
.width(120.dp),
painter = painterResource(id = movie.imageId),
contentDescription = null,
contentScale = ContentScale.Crop
)
Column(Modifier
.height(IntrinsicSize.Max)
.padding(
end = 2.dp,
)) {
Text(text = movie.title, style = MaterialTheme.typography.body1)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = movie.overview,
style = MaterialTheme.typography.body2,
maxLines = 4,
overflow = TextOverflow.Ellipsis
)
Spacer(modifier = Modifier.height(8.dp))
RatingComponent(rating = movie.rating)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment