Merge pull request #3681 from element-hq/feature/bma/rtlIssue
RTL: ensure sender information are correctly rendered in the timeline
This commit is contained in:
commit
99a5ae14ff
2 changed files with 9 additions and 2 deletions
|
|
@ -29,7 +29,9 @@ import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.CompositingStrategy
|
import androidx.compose.ui.graphics.CompositingStrategy
|
||||||
import androidx.compose.ui.graphics.Shape
|
import androidx.compose.ui.graphics.Shape
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
|
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
|
import androidx.compose.ui.unit.LayoutDirection
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import io.element.android.compound.theme.ElementTheme
|
import io.element.android.compound.theme.ElementTheme
|
||||||
import io.element.android.features.messages.impl.timeline.model.TimelineItemGroupPosition
|
import io.element.android.features.messages.impl.timeline.model.TimelineItemGroupPosition
|
||||||
|
|
@ -101,6 +103,7 @@ fun MessageEventBubble(
|
||||||
val bubbleShape = bubbleShape()
|
val bubbleShape = bubbleShape()
|
||||||
val radiusPx = (avatarRadius + SENDER_AVATAR_BORDER_WIDTH).toPx()
|
val radiusPx = (avatarRadius + SENDER_AVATAR_BORDER_WIDTH).toPx()
|
||||||
val yOffsetPx = -(NEGATIVE_MARGIN_FOR_BUBBLE + avatarRadius).toPx()
|
val yOffsetPx = -(NEGATIVE_MARGIN_FOR_BUBBLE + avatarRadius).toPx()
|
||||||
|
val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
|
||||||
BoxWithConstraints(
|
BoxWithConstraints(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.graphicsLayer {
|
.graphicsLayer {
|
||||||
|
|
@ -112,7 +115,7 @@ fun MessageEventBubble(
|
||||||
drawCircle(
|
drawCircle(
|
||||||
color = Color.Black,
|
color = Color.Black,
|
||||||
center = Offset(
|
center = Offset(
|
||||||
x = 0f,
|
x = if (isRtl) size.width else 0f,
|
||||||
y = yOffsetPx,
|
y = yOffsetPx,
|
||||||
),
|
),
|
||||||
radius = radiusPx,
|
radius = radiusPx,
|
||||||
|
|
@ -129,7 +132,9 @@ fun MessageEventBubble(
|
||||||
.testTag(TestTags.messageBubble)
|
.testTag(TestTags.messageBubble)
|
||||||
.widthIn(
|
.widthIn(
|
||||||
min = MIN_BUBBLE_WIDTH,
|
min = MIN_BUBBLE_WIDTH,
|
||||||
max = (constraints.maxWidth * BUBBLE_WIDTH_RATIO).toInt().toDp()
|
max = (constraints.maxWidth * BUBBLE_WIDTH_RATIO)
|
||||||
|
.toInt()
|
||||||
|
.toDp()
|
||||||
)
|
)
|
||||||
.clip(bubbleShape)
|
.clip(bubbleShape)
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,8 @@ private fun TimelineItemEventRowContent(
|
||||||
Modifier
|
Modifier
|
||||||
.constrainAs(sender) {
|
.constrainAs(sender) {
|
||||||
top.linkTo(parent.top)
|
top.linkTo(parent.top)
|
||||||
|
// Required for correct RTL layout
|
||||||
|
start.linkTo(parent.start)
|
||||||
}
|
}
|
||||||
.padding(horizontal = 16.dp)
|
.padding(horizontal = 16.dp)
|
||||||
.zIndex(1f)
|
.zIndex(1f)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue