Use size from the DrawScope.
This commit is contained in:
parent
9c2a08e269
commit
1127e6b854
1 changed files with 2 additions and 10 deletions
|
|
@ -18,10 +18,7 @@ import androidx.compose.foundation.layout.widthIn
|
|||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
|
|
@ -32,7 +29,6 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.graphics.CompositingStrategy
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
|
|
@ -108,7 +104,6 @@ fun MessageEventBubble(
|
|||
val radiusPx = (avatarRadius + SENDER_AVATAR_BORDER_WIDTH).toPx()
|
||||
val yOffsetPx = -(NEGATIVE_MARGIN_FOR_BUBBLE + avatarRadius).toPx()
|
||||
val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
|
||||
var contentWidthPx by remember { mutableFloatStateOf(0f) }
|
||||
BoxWithConstraints(
|
||||
modifier = modifier
|
||||
.graphicsLayer {
|
||||
|
|
@ -120,7 +115,7 @@ fun MessageEventBubble(
|
|||
drawCircle(
|
||||
color = Color.Black,
|
||||
center = Offset(
|
||||
x = if (isRtl) contentWidthPx else 0f,
|
||||
x = if (isRtl) size.width else 0f,
|
||||
y = yOffsetPx,
|
||||
),
|
||||
radius = radiusPx,
|
||||
|
|
@ -147,10 +142,7 @@ fun MessageEventBubble(
|
|||
onLongClick = onLongClick,
|
||||
indication = ripple(),
|
||||
interactionSource = interactionSource
|
||||
)
|
||||
.onGloballyPositioned { coordinates ->
|
||||
contentWidthPx = coordinates.size.width.toFloat()
|
||||
},
|
||||
),
|
||||
color = backgroundBubbleColor,
|
||||
shape = bubbleShape,
|
||||
content = content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue