feat: polish chat reply and edit composer bar
feat: replace the old action strip with a Telegram-like compact reply preview feat: show author labels, message snippets, and close action inline above the composer
This commit is contained in:
@@ -1711,28 +1711,66 @@ private fun ChatScreen(
|
||||
}
|
||||
}
|
||||
|
||||
if (state.replyToMessage != null || state.editingMessage != null) {
|
||||
val header = if (state.editingMessage != null) {
|
||||
stringResource(id = R.string.chat_editing_message, state.editingMessage.id)
|
||||
AnimatedVisibility(
|
||||
visible = state.replyToMessage != null || state.editingMessage != null,
|
||||
enter = fadeIn(),
|
||||
exit = fadeOut(),
|
||||
) {
|
||||
val composeTarget = state.editingMessage ?: state.replyToMessage
|
||||
val composeLabel = if (state.editingMessage != null) {
|
||||
stringResource(id = R.string.chat_editing_label)
|
||||
} else {
|
||||
"${stringResource(id = R.string.chat_reply_to)} ${
|
||||
state.replyToMessage?.senderDisplayName
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?: state.replyToMessage?.senderUsername?.takeIf { it.isNotBlank() }?.let { "@$it" }
|
||||
?: state.replyToMessage?.senderId?.let { senderNameByUserId[it] }
|
||||
?: stringResource(id = R.string.common_unknown_user)
|
||||
}"
|
||||
state.replyToMessage?.senderDisplayName
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?: state.replyToMessage?.senderUsername?.takeIf { it.isNotBlank() }?.let { "@$it" }
|
||||
?: state.replyToMessage?.senderId?.let { senderNameByUserId[it] }
|
||||
?: stringResource(id = R.string.common_unknown_user)
|
||||
}
|
||||
Row(
|
||||
val composeSnippet = composeTarget?.text?.takeIf { it.isNotBlank() }
|
||||
?: composeTarget?.attachments?.firstOrNull()?.fileType
|
||||
?: composeTarget?.type?.let { "[$it]" }
|
||||
?: stringResource(id = R.string.chat_compose_preview_empty)
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colorScheme.secondaryContainer)
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
.padding(horizontal = 10.dp, vertical = 4.dp),
|
||||
color = MaterialTheme.colorScheme.surface.copy(alpha = 0.92f),
|
||||
shape = RoundedCornerShape(18.dp),
|
||||
) {
|
||||
Text(text = header, style = MaterialTheme.typography.bodySmall)
|
||||
Button(onClick = onCancelComposeAction) { Text(stringResource(id = R.string.common_cancel)) }
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.width(3.dp)
|
||||
.height(34.dp)
|
||||
.clip(RoundedCornerShape(6.dp))
|
||||
.background(MaterialTheme.colorScheme.primary),
|
||||
)
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = composeLabel,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
maxLines = 1,
|
||||
)
|
||||
Text(
|
||||
text = composeSnippet,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
IconButton(onClick = onCancelComposeAction) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Close,
|
||||
contentDescription = stringResource(id = R.string.common_cancel),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,9 @@
|
||||
<string name="chat_no_available_chats">Нет доступных чатов</string>
|
||||
<string name="chat_forwarding">Пересылка...</string>
|
||||
<string name="chat_editing_message">Редактирование сообщения #%1$d</string>
|
||||
<string name="chat_editing_label">Редактирование сообщения</string>
|
||||
<string name="chat_reply_to">Ответ</string>
|
||||
<string name="chat_compose_preview_empty">Вложение</string>
|
||||
<string name="chat_delete_message_for_everyone">Удалить выбранное сообщение для всех?</string>
|
||||
<string name="chat_delete_message_for_me">Удалить выбранные сообщения у вас?</string>
|
||||
<string name="chat_clear_history_confirm">Удалить все сообщения в этом чате? Это действие нельзя отменить.</string>
|
||||
|
||||
@@ -122,7 +122,9 @@
|
||||
<string name="chat_no_available_chats">No available chats</string>
|
||||
<string name="chat_forwarding">Forwarding...</string>
|
||||
<string name="chat_editing_message">Editing message #%1$d</string>
|
||||
<string name="chat_editing_label">Editing message</string>
|
||||
<string name="chat_reply_to">Reply to</string>
|
||||
<string name="chat_compose_preview_empty">Attachment</string>
|
||||
<string name="chat_delete_message_for_everyone">Delete selected message for everyone?</string>
|
||||
<string name="chat_delete_message_for_me">Delete selected message(s) for you?</string>
|
||||
<string name="chat_clear_history_confirm">Delete all messages in this chat? This action cannot be undone.</string>
|
||||
|
||||
Reference in New Issue
Block a user