Created
August 19, 2021 18:18
-
-
Save rubenquadros/3ad0fe948341ccbdf55bb68427d8b37f to your computer and use it in GitHub Desktop.
Game Item composable
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
@Composable | |
fun GameItem(game: GameResultsEntity) { | |
Card( | |
elevation = 20.dp, | |
backgroundColor = Color.Black, | |
modifier = | |
Modifier.padding(16.dp) | |
.clip(RoundedCornerShape(10.dp)) | |
.height(250.dp) | |
.fillMaxWidth() | |
) { | |
ConstraintLayout { | |
val (image, title, rating) = createRefs() | |
Image( | |
contentScale = ContentScale.Crop, | |
painter = | |
rememberImagePainter( | |
data = game.backgroundImage, | |
builder = { | |
placeholder( | |
R.drawable | |
.ic_esports_placeholder | |
) | |
crossfade(true) | |
} | |
), | |
contentDescription = "Image", | |
modifier = | |
Modifier.constrainAs(image) { | |
top.linkTo(parent.top) | |
start.linkTo(parent.start) | |
end.linkTo(parent.end) | |
} | |
.height(150.dp) | |
.fillMaxWidth() | |
) | |
Text( | |
text = game.name, | |
color = Color(0xFFF50057), | |
maxLines = 2, | |
fontSize = 20.sp, | |
fontWeight = FontWeight.Bold, | |
modifier = | |
Modifier.constrainAs(title) { | |
top.linkTo(image.bottom) | |
start.linkTo(parent.start) | |
end.linkTo(parent.end) | |
} | |
.fillMaxWidth() | |
.padding(8.dp) | |
) | |
Row( | |
modifier = | |
Modifier.fillMaxWidth().constrainAs( | |
rating | |
) { | |
bottom.linkTo(parent.bottom) | |
start.linkTo(parent.start) | |
end.linkTo(parent.end) | |
} | |
) { | |
Text( | |
text = game.rating.toString(), | |
color = Color(0xFFFFC400), | |
modifier = Modifier.padding(8.dp), | |
fontSize = 18.sp | |
) | |
Image( | |
contentScale = ContentScale.Crop, | |
painter = | |
painterResource( | |
id = R.drawable.ic_star | |
), | |
contentDescription = "Star", | |
modifier = Modifier.padding(top = 10.dp) | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment