android: add reply and forwarded blocks to chat bubbles
Some checks failed
CI / test (push) Failing after 2m9s
Some checks failed
CI / test (push) Failing after 2m9s
This commit is contained in:
@@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
@@ -399,16 +400,51 @@ private fun MessageBubble(
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
}
|
||||
if (message.forwardedFromMessageId != null || !message.forwardedFromDisplayName.isNullOrBlank()) {
|
||||
Text(
|
||||
text = "Forwarded from ${message.forwardedFromDisplayName?.takeIf { it.isNotBlank() } ?: "#${message.forwardedFromMessageId ?: "?"}"}",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = if (isOutgoing) {
|
||||
MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.78f)
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.78f)
|
||||
},
|
||||
)
|
||||
}
|
||||
if (message.replyToMessageId != null) {
|
||||
val replyAuthor = message.replyPreviewSenderName?.takeIf { it.isNotBlank() }
|
||||
?: "#${message.replyToMessageId}"
|
||||
val replySnippet = message.replyPreviewText?.takeIf { it.isNotBlank() } ?: "[media]"
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
.background(
|
||||
color = if (isOutgoing) {
|
||||
MaterialTheme.colorScheme.onPrimaryContainer.copy(alpha = 0.16f)
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.16f)
|
||||
},
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
)
|
||||
.padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
) {
|
||||
Text(
|
||||
text = replyAuthor,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
)
|
||||
Text(
|
||||
text = replySnippet,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
maxLines = 2,
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = message.text ?: "[${message.type}]",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
if (message.forwardedFromMessageId != null) {
|
||||
Text(
|
||||
text = "Forwarded from #${message.forwardedFromMessageId}",
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
)
|
||||
}
|
||||
if (reactions.isNotEmpty()) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
reactions.forEach { reaction ->
|
||||
|
||||
Reference in New Issue
Block a user