Правка ответов, локализация, поддержка медиа
This commit is contained in:
@@ -123,7 +123,22 @@ fun MessageBubble(
|
||||
.width(2.dp)
|
||||
.background(if (isCurrentUser) Color.White else Color(0xFF3096E5))
|
||||
)
|
||||
Column(modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp)) {
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val isReplyImage = reply.mediaType == MediaType.IMAGE || reply.mediaType == MediaType.VIDEO || reply.mediaType == MediaType.GIF
|
||||
|
||||
if (isReplyImage && reply.media.isNotEmpty()) {
|
||||
AsyncImage(
|
||||
model = reply.media.first().url,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.width(40.dp)
|
||||
.clip(RoundedCornerShape(0.dp, 4.dp, 4.dp, 0.dp)),
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
}
|
||||
|
||||
Column(modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp).weight(1f)) {
|
||||
val accentColor = if (isCurrentUser) Color.White else Color(0xFF3096E5)
|
||||
Text(
|
||||
text = reply.senderName,
|
||||
@@ -132,8 +147,32 @@ fun MessageBubble(
|
||||
maxLines = 1,
|
||||
fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
|
||||
)
|
||||
|
||||
val photoText = androidx.compose.ui.res.stringResource(ru.knot.messager.R.string.reply_photo)
|
||||
val videoText = androidx.compose.ui.res.stringResource(ru.knot.messager.R.string.reply_video)
|
||||
val voiceText = androidx.compose.ui.res.stringResource(ru.knot.messager.R.string.voice_message)
|
||||
val audioText = androidx.compose.ui.res.stringResource(ru.knot.messager.R.string.reply_audio)
|
||||
val fileText = androidx.compose.ui.res.stringResource(ru.knot.messager.R.string.reply_file)
|
||||
val gifText = androidx.compose.ui.res.stringResource(ru.knot.messager.R.string.reply_gif)
|
||||
val mediaText = androidx.compose.ui.res.stringResource(ru.knot.messager.R.string.media)
|
||||
|
||||
val replyText = remember(reply) {
|
||||
if (!reply.content.isNullOrEmpty()) {
|
||||
reply.content
|
||||
} else {
|
||||
when (reply.mediaType) {
|
||||
MediaType.IMAGE -> photoText
|
||||
MediaType.VIDEO -> videoText
|
||||
MediaType.AUDIO -> if (reply.media.any { it.type == "voice" }) voiceText else audioText
|
||||
MediaType.FILE -> fileText
|
||||
MediaType.GIF -> gifText
|
||||
else -> mediaText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
text = reply.content ?: if (reply.media.isNotEmpty()) "\uD83D\uDCCE Media" else "",
|
||||
text = replyText,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = contentColor.copy(alpha = 0.8f),
|
||||
maxLines = 1,
|
||||
|
||||
Reference in New Issue
Block a user