Fix setting y offset to -12.dp can overlap a state event displayed above. Rework how the vertical offset are applied.

This commit is contained in:
Benoit Marty
2023-05-26 16:56:13 +02:00
committed by Benoit Marty
parent 7b0d21e884
commit 928e3f680b
56 changed files with 110 additions and 103 deletions

View File

@@ -247,14 +247,16 @@ fun TimelineItemEventRow(
) {
Row {
if (!event.isMine) {
Spacer(modifier = Modifier.width(16.dp))
Spacer(modifier = Modifier.width(4.dp))
}
Column(horizontalAlignment = contentAlignment) {
if (event.showSenderInformation) {
MessageSenderInformation(
event.safeSenderName,
event.senderAvatar,
Modifier.zIndex(1f)
Modifier
.zIndex(1f)
.offset(y = 12.dp)
)
}
val bubbleState = BubbleState(
@@ -282,7 +284,7 @@ fun TimelineItemEventRow(
reactionsState = event.reactionsState,
modifier = Modifier
.zIndex(1f)
.offset(x = if (event.isMine) 0.dp else 20.dp, y = -(16.dp))
.offset(x = if (event.isMine) 0.dp else 20.dp, y = -(4.dp))
)
}
if (event.isMine) {

View File

@@ -86,10 +86,9 @@ fun MessageEventBubble(
fun Modifier.offsetForItem(): Modifier {
return if (state.isMine) {
// FIXME setting y offset to -12.dp can overlap a state event displayed above.
offset(y = -(12.dp))
this
} else {
offset(x = 20.dp, y = -(12.dp))
offset(x = 20.dp)
}
}
@@ -132,7 +131,7 @@ internal fun MessageEventBubbleDarkPreview(@PreviewParameter(BubbleStateProvider
@Composable
private fun ContentToPreview(state: BubbleState) {
// Due to y offset, surround with a Box
// Due to position offset, surround with a Box
Box(
modifier = Modifier
.size(width = 240.dp, height = 64.dp)