Merge pull request #596 from barrydeen/fix/chat-bubble-subcompose-crash

fix: avoid intrinsic measurement of chat bubble content (SubcomposeLayout crash)
This commit is contained in:
Barry Deen
2026-06-18 11:42:43 -04:00
committed by GitHub
2 changed files with 4 additions and 6 deletions
@@ -200,6 +200,7 @@ fun DmBubble(
modifier = Modifier.weight(1f, fill = isSent),
contentAlignment = if (isSent) Alignment.BottomEnd else Alignment.BottomStart
) {
val bubbleMaxWidth = maxWidth
@OptIn(ExperimentalFoundationApi::class)
Box(
modifier = Modifier
@@ -221,13 +222,11 @@ fun DmBubble(
) {
Column(
modifier = Modifier
.width(IntrinsicSize.Max)
.padding(horizontal = 12.dp, vertical = 8.dp)
) {
// Header row: sender name + timestamp (received messages only)
if (!isSent) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
@@ -238,7 +237,7 @@ fun DmBubble(
color = MaterialTheme.colorScheme.primary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f)
modifier = Modifier.widthIn(max = bubbleMaxWidth - 96.dp)
)
Text(
text = formatTime(message.createdAt),
@@ -1346,6 +1346,7 @@ private fun GroupMessageBubble(
modifier = Modifier.weight(1f, fill = isOwnMessage),
contentAlignment = if (isOwnMessage) Alignment.BottomEnd else Alignment.BottomStart
) {
val bubbleMaxWidth = maxWidth
Surface(
shape = if (isOwnMessage)
RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp, bottomEnd = 4.dp, bottomStart = 16.dp)
@@ -1359,13 +1360,11 @@ private fun GroupMessageBubble(
) {
Column(
modifier = Modifier
.width(IntrinsicSize.Max)
.padding(horizontal = 12.dp, vertical = 8.dp)
) {
// Header row hidden for own messages
if (!isOwnMessage) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
@@ -1375,7 +1374,7 @@ private fun GroupMessageBubble(
color = nameColor,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(1f)
modifier = Modifier.widthIn(max = bubbleMaxWidth - 96.dp)
)
if (hasZaps) {
Text(