Merge pull request #1093 from vector-im/feature/bma/senderNameBubble

Feature/bma/sender name bubble
This commit is contained in:
Benoit Marty 2023-08-18 15:59:20 +02:00 committed by GitHub
commit 13e22705b9
4 changed files with 37 additions and 6 deletions

1
changelog.d/1033.bugfix Normal file
View file

@ -0,0 +1 @@
Timeline: sender names are now displayed in one single line.

View file

@ -106,6 +106,7 @@ internal fun aTimelineItemEvent(
eventId: EventId = EventId("\$" + Random.nextInt().toString()), eventId: EventId = EventId("\$" + Random.nextInt().toString()),
transactionId: TransactionId? = null, transactionId: TransactionId? = null,
isMine: Boolean = false, isMine: Boolean = false,
senderDisplayName: String = "Sender",
content: TimelineItemEventContent = aTimelineItemTextContent(), content: TimelineItemEventContent = aTimelineItemTextContent(),
groupPosition: TimelineItemGroupPosition = TimelineItemGroupPosition.None, groupPosition: TimelineItemGroupPosition = TimelineItemGroupPosition.None,
sendState: LocalEventSendState = LocalEventSendState.Sent(eventId), sendState: LocalEventSendState = LocalEventSendState.Sent(eventId),
@ -123,7 +124,7 @@ internal fun aTimelineItemEvent(
reactionsState = timelineItemReactions, reactionsState = timelineItemReactions,
sentTime = "12:34", sentTime = "12:34",
isMine = isMine, isMine = isMine,
senderDisplayName = "Sender", senderDisplayName = senderDisplayName,
groupPosition = groupPosition, groupPosition = groupPosition,
localSendState = sendState, localSendState = sendState,
inReplyTo = inReplyTo, inReplyTo = inReplyTo,
@ -141,11 +142,13 @@ fun aTimelineItemReactions(
reactions = buildList { reactions = buildList {
repeat(count) { index -> repeat(count) { index ->
val key = emojis[index % emojis.size] val key = emojis[index % emojis.size]
add(anAggregatedReaction( add(
key = key, anAggregatedReaction(
count = index + 1, key = key,
isHighlighted = isHighlighted count = index + 1,
)) isHighlighted = isHighlighted
)
)
} }
}.toPersistentList() }.toPersistentList()
) )

View file

@ -340,6 +340,8 @@ private fun MessageSenderInformation(
Spacer(modifier = Modifier.width(4.dp)) Spacer(modifier = Modifier.width(4.dp))
Text( Text(
text = sender, text = sender,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
color = MaterialTheme.colorScheme.primary, color = MaterialTheme.colorScheme.primary,
style = ElementTheme.typography.fontBodyMdMedium, style = ElementTheme.typography.fontBodyMdMedium,
) )
@ -786,3 +788,25 @@ private fun ContentWithManyReactionsToPreview() {
} }
} }
} }
// Note: no need for light/dark variant for this preview
@Preview
@Composable
internal fun TimelineItemEventRowLongSenderNamePreview() = ElementPreviewLight {
TimelineItemEventRow(
event = aTimelineItemEvent(
senderDisplayName = "a long sender display name to test single line and ellipsis at the end of the line",
),
isHighlighted = false,
canReply = true,
onClick = {},
onLongClick = {},
onUserDataClick = {},
inReplyToClick = {},
onReactionClick = { _, _ -> },
onReactionLongClick = { _, _ -> },
onMoreReactionsClick = {},
onSwipeToReply = {},
onTimestampClicked = {},
)
}

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cb071f845598b35931253304f4c9f4c865b5fe9f57662c03c88a0c94a7835d83
size 18615