Jakob Lindell
11/28/2024, 2:43 PMAlexanderiaddd Montgomerysoe
I want the name text to wrap the content and not occupy the full width since it creates a space between the two text compostables , is this possible to achieve?Jakob Lindell
11/28/2024, 2:43 PM@Composable
fun TestComposable(name: String) {
Row(
modifier = Modifier
.background(Color.White)
.wrapContentWidth()
.padding(8.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start,
) {
Icon(
imageVector = Icons.Default.Face,
contentDescription = "PlaceholderIcon",
modifier = Modifier.size(48.dp),
tint = Color.Red,
)
Text(
modifier = Modifier
.padding(horizontal = 12.dp)
.offset(y = (-2).dp)
.widthIn(max = 190.dp)
.background(Color.Green),
text = name,
style = Typography.bodyMedium,
color = Color.Black,
overflow = TextOverflow.Ellipsis,
maxLines = 2,
softWrap = true,
)
Text(
modifier = Modifier
.clip(CircleShape)
.wrapContentWidth()
.background(Color.Cyan)
.padding(
start = 8.dp,
end = 8.dp,
top = 4.dp,
bottom = 6.dp,
),
style = Typography.bodyMedium,
text = "Not at the desk",
color = Color.Black,
maxLines = 1,
)
}
}
private class NamesPreviewProvider : PreviewParameterProvider<String> {
override val values: Sequence<String> = listOf(
// "Jo Lee",
// "Ty Wu",
// "Ana Kim",
// "Scarlett Davis",
"Benjamin Williams Something",
"Alexanderiaddd Montgomerysoe",
"Benjami bb Button aaa the third of something blabla",
).asSequence()
}
@Preview
@Composable
private fun TestComposablePreview(@PreviewParameter(NamesPreviewProvider::class) name: String) {
TestComposable(name)
}
Stylianos Gakis
11/28/2024, 2:44 PMJakob Lindell
11/28/2024, 2:47 PMJakob Lindell
11/28/2024, 2:53 PMStylianos Gakis
11/28/2024, 2:57 PMJakob Lindell
11/28/2024, 3:00 PM