Last active
April 25, 2021 13:30
-
-
Save raulh82vlc/c2882737a991898814fa0aba876a174f to your computer and use it in GitHub Desktop.
TweetBox 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 TweetBox(tweet: Tweet, onClick: () -> Unit ) { | |
Box( | |
modifier = Modifier | |
.border( | |
width = 1.dp, | |
color = Color.LightGray, | |
shape = RoundedCornerShape(16.dp) | |
) | |
.fillMaxWidth() | |
.clickable(onClick = onClick) | |
.padding(6.dp), | |
) { | |
val user = tweet.user ?: "" | |
val imageUrl: String = tweet.images[0] | |
Column( | |
modifier = Modifier | |
.fillMaxWidth() | |
.padding(10.dp), | |
verticalArrangement = Arrangement.SpaceBetween, | |
horizontalAlignment = Alignment.CenterHorizontally, | |
) { | |
Image( | |
painter = rememberCoilPainter( | |
request = imageUrl, | |
shouldRefetchOnSizeChange = { _, _ -> false }, | |
), | |
contentDescription = "$user image thumbnail", | |
modifier = Modifier | |
.size(60.dp), | |
) | |
Spacer(modifier = Modifier.height(10.dp)) | |
Text(text = user, | |
style = TextStyle( | |
color = Color.Blue | |
), | |
textAlign = TextAlign.Center, | |
maxLines = 1 | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment