From f2b52d1a5d4eed47956b8a3bf5f0a9b41785d015 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 29 Jun 2023 17:58:38 +0200 Subject: [PATCH] Reply preview on 2 lines. --- .../components/TimelineItemEventRow.kt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt index 3d0b89e04f..59d824ce86 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/TimelineItemEventRow.kt @@ -379,7 +379,7 @@ private fun ReplyToContent( style = ElementTheme.typography.fontBodyMdRegular, textAlign = TextAlign.Start, color = ElementTheme.materialColors.secondary, - maxLines = 1, + maxLines = 2, overflow = TextOverflow.Ellipsis, ) } @@ -472,6 +472,13 @@ internal fun TimelineItemEventRowWithReplyDarkPreview() = private fun ContentToPreviewWithReply() { Column { sequenceOf(false, true).forEach { + val replyContent = if(it) { + // Short + "Message which are being replied." + } else { + // Long, to test 2 lines and ellipsis) + "Message which are being replied, and which was long enough to be displayed on two lines (only!)." + } TimelineItemEventRow( event = aTimelineItemEvent( isMine = it, @@ -479,7 +486,7 @@ private fun ContentToPreviewWithReply() { body = "A long text which will be displayed on several lines and" + " hopefully can be manually adjusted to test different behaviors." ), - inReplyTo = aInReplyToReady() + inReplyTo = aInReplyToReady(replyContent) ), isHighlighted = false, onClick = {}, @@ -495,7 +502,7 @@ private fun ContentToPreviewWithReply() { content = aTimelineItemImageContent().copy( aspectRatio = 5f ), - inReplyTo = aInReplyToReady() + inReplyTo = aInReplyToReady(replyContent) ), isHighlighted = false, onClick = {}, @@ -509,10 +516,12 @@ private fun ContentToPreviewWithReply() { } } -private fun aInReplyToReady(): InReplyTo.Ready { +private fun aInReplyToReady( + replyContent: String +): InReplyTo.Ready { return InReplyTo.Ready( eventId = EventId("\$event"), - content = MessageContent("Message which are being replied.", null, false, TextMessageType("Message", null)), + content = MessageContent(replyContent, null, false, TextMessageType(replyContent, null)), senderId = UserId("@Sender:domain"), senderDisplayName = "Sender", senderAvatarUrl = null,