Skip to content

Instantly share code, notes, and snippets.

@satadii11
Created November 25, 2021 09:08
Show Gist options
  • Save satadii11/055c569655c6e6f2c8b525fc6f80d39c to your computer and use it in GitHub Desktop.
Save satadii11/055c569655c6e6f2c8b525fc6f80d39c to your computer and use it in GitHub Desktop.
@Composable
private fun AnimeCard(animeModel: AnimeModel) {
Card(
shape = RoundedCornerShape(8.dp),
modifier = Modifier
.fillMaxWidth()
.padding(8.dp, 4.dp),
elevation = 8.dp,
backgroundColor = if (animeModel.majorColor.isEmpty()) MaterialTheme.colors.primary
else Color(android.graphics.Color.parseColor(animeModel.majorColor))
) {
Row {
CoilImage(
modifier = Modifier
.padding(end = 8.dp)
.width(100.dp)
.height(100.dp),
imageModel = animeModel.coverImage
)
Column(
modifier = Modifier
.padding(end = 8.dp)
.align(Alignment.CenterVertically),
verticalArrangement = Arrangement.Center
) {
LazyRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
items(animeModel.genres, key = { it }) {
Text(
color = Color.White,
text = it,
fontSize = 10.sp,
modifier = Modifier
.background(Color.Gray, CircleShape)
.padding(8.dp, 4.dp)
)
}
}
Text(
text = animeModel.title,
fontSize = 16.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontWeight = FontWeight.Bold,
color = MaterialTheme.colors.onPrimary,
modifier = Modifier.fillMaxWidth()
)
Text(
text = "Average Score: ${animeModel.averageScore}%",
color = MaterialTheme.colors.onPrimary
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment