Skip to content

Instantly share code, notes, and snippets.

@raulh82vlc
Last active April 25, 2021 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulh82vlc/c2882737a991898814fa0aba876a174f to your computer and use it in GitHub Desktop.
Save raulh82vlc/c2882737a991898814fa0aba876a174f to your computer and use it in GitHub Desktop.
TweetBox composable
@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