Created
March 21, 2022 13:55
-
-
Save alexstyl/61f5a4b4655ca3c1689bc9673c880105 to your computer and use it in GitHub Desktop.
Code sample for composables.co
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 ConversationItem( | |
modifier: Modifier = Modifier, | |
onClick: () -> Unit, | |
title: String, | |
snippet: String, | |
unread: Boolean = false, | |
timestamp: String, | |
profilePainters: List<Painter>, | |
) { | |
val typeAlpha = if (unread) { | |
ContentAlpha.high | |
} else { | |
ContentAlpha.medium | |
} | |
Surface( | |
modifier = modifier | |
.padding(horizontal = 8.dp, vertical = 4.dp) | |
.clip(MaterialTheme.shapes.medium) | |
.clickable { | |
onClick() | |
}, | |
color = MaterialTheme.colors.background, | |
) { | |
Row( | |
Modifier | |
.padding(horizontal = 8.dp, vertical = 16.dp), | |
verticalAlignment = Alignment.CenterVertically | |
) { | |
ConversationPhoto( | |
painters = profilePainters | |
) | |
Spacer(Modifier.width(20.dp)) | |
Column(modifier = Modifier.weight(1f)) { | |
Row { | |
Text( | |
title, modifier = Modifier.weight(1f), | |
style = MaterialTheme.typography.body1, | |
) | |
Spacer(Modifier.width(10.dp)) | |
Text( | |
timestamp, | |
style = MaterialTheme.typography.body2, | |
modifier = Modifier.alpha(typeAlpha) | |
) | |
} | |
Spacer(Modifier.height(8.dp)) | |
Text( | |
snippet, | |
modifier = Modifier.alpha(typeAlpha), | |
style = MaterialTheme.typography.body2 | |
) | |
} | |
} | |
} | |
} |
thanks @EmilioMezaE
the ConversationPhoto and much more is included in the Chat UI Kit in Https://composables.co. check it out
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @alexstyl,
Great code!
It's just missing the implementation for the function ConversationPhoto. Could it be possible for you to post it?