Rework timestamp position.

Add extra empty text to message content to avoid timestamp to overlap the text.
This commit is contained in:
Benoit Marty
2023-06-23 09:38:07 +02:00
committed by Benoit Marty
parent d608c9b9c6
commit 50945e987a
6 changed files with 29 additions and 7 deletions

View File

@@ -253,13 +253,13 @@ private fun MessageEventBubbleContent(
)
}
} else {
Column(modifier) {
ContentView(modifier = contentModifier.padding(start = 12.dp, end = 12.dp, top = 8.dp))
Box(modifier) {
ContentView(modifier = contentModifier.padding(start = 12.dp, end = 12.dp, top = 8.dp, bottom = 8.dp))
TimelineEventTimestampView(
event = event,
onClick = onTimestampClicked,
modifier = timestampModifier
.align(Alignment.End)
.align(Alignment.BottomEnd)
.padding(horizontal = 8.dp, vertical = 4.dp)
)
}

View File

@@ -58,7 +58,7 @@ fun TimelineItemInformativeView(
fontStyle = FontStyle.Italic,
color = MaterialTheme.colorScheme.secondary,
fontSize = 14.sp,
text = text
text = text + extraPaddingTrick
)
}
}

View File

@@ -33,7 +33,7 @@ fun TimelineItemRedactedView(
modifier: Modifier = Modifier
) {
TimelineItemInformativeView(
text = stringResource(id = CommonStrings.common_message_removed),
text = stringResource(id = CommonStrings.common_message_removed) + extraPaddingTrick,
iconDescription = stringResource(id = CommonStrings.common_message_removed),
icon = Icons.Default.Delete,
modifier = modifier

View File

@@ -37,6 +37,7 @@ import io.element.android.libraries.designsystem.components.ClickableLinkText
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.libraries.theme.LinkColor
import io.element.android.libraries.designsystem.text.toAnnotatedString
@Composable
fun TimelineItemTextView(
@@ -60,7 +61,7 @@ fun TimelineItemTextView(
val linkStyle = SpanStyle(
color = LinkColor,
)
val styledText = remember(content.body) { content.body.linkify(linkStyle) }
val styledText = remember(content.body) { content.body.linkify(linkStyle) + extraPaddingTrick.toAnnotatedString() }
ClickableLinkText(
text = styledText,
linkAnnotationTag = "URL",

View File

@@ -33,7 +33,7 @@ fun TimelineItemUnknownView(
modifier: Modifier = Modifier
) {
TimelineItemInformativeView(
text = stringResource(id = CommonStrings.common_unsupported_event),
text = stringResource(id = CommonStrings.common_unsupported_event) + extraPaddingTrick,
iconDescription = stringResource(id = CommonStrings.dialog_title_warning),
icon = Icons.Default.Info,
modifier = modifier

View File

@@ -0,0 +1,21 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.features.messages.impl.timeline.components.event
// Allow to not overlap the timestamp with the text, in the message bubble.
// Compute the size of the worst case.
val extraPaddingTrick: String = " ".repeat(" (edited) 88:88 X ".length)