|
|
|
|
@ -26,6 +26,8 @@ import androidx.compose.runtime.*
|
|
|
|
|
import androidx.compose.ui.Alignment |
|
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
|
import androidx.compose.ui.draw.clip |
|
|
|
|
import androidx.compose.ui.draw.drawBehind |
|
|
|
|
import androidx.compose.ui.geometry.CornerRadius |
|
|
|
|
import androidx.compose.ui.geometry.Offset |
|
|
|
|
import androidx.compose.ui.geometry.Size |
|
|
|
|
import androidx.compose.ui.focus.FocusRequester |
|
|
|
|
@ -101,7 +103,7 @@ fun MessageBubble(message: Message, playbackState: ChatViewModel.PlaybackState =
|
|
|
|
|
onOpenFile: (Message) -> Unit = {}, |
|
|
|
|
onOpenImage: (Message) -> Unit = {}, |
|
|
|
|
onPlayVideo: (Message) -> Unit = {}) { |
|
|
|
|
val bgColor = if (message.isOutgoing) ChatColors.Outgoing else ChatColors.Raised |
|
|
|
|
val bgColor = if (message.isOutgoing) ChatColors.OutgoingBubble else ChatColors.IncomingBubble |
|
|
|
|
val textColor = ChatColors.Text |
|
|
|
|
val alignment = if (message.isOutgoing) Arrangement.End else Arrangement.Start |
|
|
|
|
val minBubbleWidth = (LocalConfiguration.current.screenWidthDp / 3).dp |
|
|
|
|
@ -134,7 +136,14 @@ fun MessageBubble(message: Message, playbackState: ChatViewModel.PlaybackState =
|
|
|
|
|
) { |
|
|
|
|
Column( |
|
|
|
|
modifier = Modifier |
|
|
|
|
.widthIn(min = minBubbleWidth, max = if (isVoice) voiceMaxWidth else 300.dp) |
|
|
|
|
.widthIn(min = minBubbleWidth, max = if (isVoice) voiceMaxWidth else 300.dp) |
|
|
|
|
// Тень рисуем до clip, чтобы выступающие справа и снизу края оставались видны. |
|
|
|
|
.drawBehind { |
|
|
|
|
val offset = 2.dp.toPx() |
|
|
|
|
val radius = 12.dp.toPx() |
|
|
|
|
drawRoundRect(ChatColors.BubbleShadow, topLeft = Offset(offset, offset), size = size, |
|
|
|
|
cornerRadius = CornerRadius(radius, radius)) |
|
|
|
|
} |
|
|
|
|
.clip(RoundedCornerShape(12.dp)) |
|
|
|
|
.background(bgColor) |
|
|
|
|
.padding(12.dp) |
|
|
|
|
|