Skip to content

Instantly share code, notes, and snippets.

@alexstyl
Created March 21, 2022 13:55
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 alexstyl/61f5a4b4655ca3c1689bc9673c880105 to your computer and use it in GitHub Desktop.
Save alexstyl/61f5a4b4655ca3c1689bc9673c880105 to your computer and use it in GitHub Desktop.
Code sample for composables.co
@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
)
}
}
}
}
@EmilioMezaE
Copy link

Hi @alexstyl,
Great code!
It's just missing the implementation for the function ConversationPhoto. Could it be possible for you to post it?

@alexstyl
Copy link
Author

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