RoomSummary: move the icon related to the last message state on start of the message.

This commit is contained in:
Benoit Marty 2025-12-11 13:52:30 +01:00
parent cf00b799f2
commit 6d93ce25aa

View file

@ -121,7 +121,6 @@ internal fun RoomSummaryRow(
) { ) {
NameAndTimestampRow( NameAndTimestampRow(
name = room.name, name = room.name,
latestEvent = room.latestEvent,
timestamp = room.timestamp, timestamp = room.timestamp,
isHighlighted = room.isHighlighted isHighlighted = room.isHighlighted
) )
@ -138,7 +137,6 @@ internal fun RoomSummaryRow(
) { ) {
NameAndTimestampRow( NameAndTimestampRow(
name = room.name, name = room.name,
latestEvent = room.latestEvent,
timestamp = null, timestamp = null,
isHighlighted = room.isHighlighted isHighlighted = room.isHighlighted
) )
@ -214,7 +212,6 @@ private fun RoomSummaryScaffoldRow(
@Composable @Composable
private fun NameAndTimestampRow( private fun NameAndTimestampRow(
name: String?, name: String?,
latestEvent: LatestEvent,
timestamp: String?, timestamp: String?,
isHighlighted: Boolean, isHighlighted: Boolean,
modifier: Modifier = Modifier modifier: Modifier = Modifier
@ -236,29 +233,6 @@ private fun NameAndTimestampRow(
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis
) )
// Picto
when (latestEvent) {
is LatestEvent.Sending -> {
Spacer(modifier = Modifier.width(4.dp))
Icon(
modifier = Modifier.size(16.dp),
imageVector = CompoundIcons.Time(),
contentDescription = stringResource(CommonStrings.common_sending),
tint = ElementTheme.colors.iconTertiary,
)
}
is LatestEvent.Error -> {
Spacer(modifier = Modifier.width(4.dp))
Icon(
modifier = Modifier.size(16.dp),
imageVector = CompoundIcons.ErrorSolid(),
// The last message contains the error.
contentDescription = null,
tint = ElementTheme.colors.iconCriticalPrimary,
)
}
else -> Unit
}
} }
// Timestamp // Timestamp
Text( Text(
@ -303,7 +277,6 @@ private fun MessagePreviewAndIndicatorRow(
) { ) {
Row( Row(
modifier = modifier.fillMaxWidth(), modifier = modifier.fillMaxWidth(),
horizontalArrangement = spacedBy(28.dp)
) { ) {
if (room.isTombstoned) { if (room.isTombstoned) {
Text( Text(
@ -317,6 +290,16 @@ private fun MessagePreviewAndIndicatorRow(
) )
} else { } else {
if (room.latestEvent is LatestEvent.Error) { if (room.latestEvent is LatestEvent.Error) {
Icon(
modifier = Modifier
.padding(top = 2.dp)
.size(16.dp),
imageVector = CompoundIcons.ErrorSolid(),
// The last message contains the error.
contentDescription = null,
tint = ElementTheme.colors.iconCriticalPrimary,
)
Spacer(modifier = Modifier.width(6.dp))
Text( Text(
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
text = stringResource(CommonStrings.common_message_failed_to_send), text = stringResource(CommonStrings.common_message_failed_to_send),
@ -327,6 +310,17 @@ private fun MessagePreviewAndIndicatorRow(
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
) )
} else { } else {
if (room.latestEvent is LatestEvent.Sending) {
Icon(
modifier = Modifier
.padding(top = 2.dp)
.size(16.dp),
imageVector = CompoundIcons.Time(),
contentDescription = stringResource(CommonStrings.common_sending),
tint = ElementTheme.colors.iconTertiary,
)
Spacer(modifier = Modifier.width(6.dp))
}
val messagePreview = room.latestEvent.content() val messagePreview = room.latestEvent.content()
val annotatedMessagePreview = messagePreview as? AnnotatedString ?: AnnotatedString(text = messagePreview.orEmpty().toString()) val annotatedMessagePreview = messagePreview as? AnnotatedString ?: AnnotatedString(text = messagePreview.orEmpty().toString())
Text( Text(
@ -340,7 +334,7 @@ private fun MessagePreviewAndIndicatorRow(
) )
} }
} }
Spacer(modifier = Modifier.width(16.dp))
// Call and unread // Call and unread
Row( Row(
modifier = Modifier modifier = Modifier