Реакции, но с багом
This commit is contained in:
@@ -270,10 +270,14 @@ fun ChatDetailScreen(
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = { /* TODO: Forward */ }) {
|
||||
IconButton(onClick = {
|
||||
viewModel.onForwardSelectedMessages()
|
||||
}) {
|
||||
Icon(Icons.Default.Forward, contentDescription = "Forward")
|
||||
}
|
||||
IconButton(onClick = { /* TODO: Delete */ }) {
|
||||
IconButton(onClick = {
|
||||
// TODO: Bulk Delete
|
||||
}) {
|
||||
Icon(Icons.Default.Delete, contentDescription = "Delete")
|
||||
}
|
||||
}
|
||||
@@ -363,6 +367,7 @@ fun ChatDetailScreen(
|
||||
initialPlaybackSpeed = if (item.message.id == autoPlayingMessageId) currentPlaybackSpeed else 1.0f,
|
||||
onVoiceFinished = { speed -> playNextVoiceMessage(item.message.id, speed) },
|
||||
onReactionClick = { emoji -> viewModel.addReaction(item.message.id, emoji) },
|
||||
onReply = { msg -> viewModel.onReply(msg) },
|
||||
onReplyClick = { reply ->
|
||||
val index = listItems.indexOfFirst {
|
||||
it is MessageListItem.MessageItem && it.message.id == reply.id
|
||||
@@ -372,6 +377,10 @@ fun ChatDetailScreen(
|
||||
}
|
||||
},
|
||||
onSelect = { viewModel.toggleSelection(it) },
|
||||
onForward = { viewModel.onForward(it) },
|
||||
onPin = { viewModel.onPin(it) },
|
||||
onEdit = { viewModel.onEdit(it) },
|
||||
onDelete = { msg, forEveryone -> viewModel.deleteMessage(msg, forEveryone) },
|
||||
isSelected = state.selectedMessageIds.contains(item.message.id),
|
||||
isSelectionMode = state.selectedMessageIds.isNotEmpty(),
|
||||
onMediaClick = { clickedMedia ->
|
||||
@@ -725,6 +734,52 @@ fun ChatDetailScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// Edit Preview Bar
|
||||
state.editingMessage?.let { editMsg ->
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp, vertical = 4.dp)
|
||||
.height(IntrinsicSize.Min),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxHeight()
|
||||
.width(2.dp)
|
||||
.background(MaterialTheme.colorScheme.primary)
|
||||
)
|
||||
Icon(
|
||||
imageVector = Icons.Default.Edit,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.padding(start = 8.dp).size(20.dp)
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 8.dp, vertical = 2.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "Редактирование",
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
Text(
|
||||
text = editMsg.content ?: "",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
IconButton(onClick = { viewModel.cancelEdit() }) {
|
||||
Icon(Icons.Default.Close, contentDescription = "Cancel", modifier = Modifier.size(20.dp), tint = Color.Gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@@ -929,6 +984,52 @@ fun ChatDetailScreen(
|
||||
onClose = { selectedMediaList = null }
|
||||
)
|
||||
}
|
||||
|
||||
if (state.forwardingMessages.isNotEmpty()) {
|
||||
ForwardChatSelectionDialog(
|
||||
chats = state.availableChatsToForward,
|
||||
onChatSelected = { targetChatId ->
|
||||
viewModel.forwardMessages(targetChatId, state.forwardingMessages)
|
||||
viewModel.cancelForwarding()
|
||||
viewModel.clearSelection()
|
||||
},
|
||||
onDismiss = { viewModel.cancelForwarding() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ForwardChatSelectionDialog(
|
||||
chats: List<chats.domain.model.Chat>,
|
||||
onChatSelected: (String) -> Unit,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text("Выберите чат для пересылки") },
|
||||
text = {
|
||||
LazyColumn(modifier = Modifier.fillMaxWidth().heightIn(max = 400.dp)) {
|
||||
items(chats) { chat ->
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { onChatSelected(chat.id) }
|
||||
.padding(vertical = 12.dp, horizontal = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
AppAvatar(url = chat.avatar, name = chat.name, size = 40.dp)
|
||||
Spacer(Modifier.width(12.dp))
|
||||
Text(chat.name, style = MaterialTheme.typography.bodyLarge)
|
||||
}
|
||||
Divider(color = Color.Gray.copy(alpha = 0.2f))
|
||||
}
|
||||
}
|
||||
},
|
||||
confirmButton = {},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismiss) { Text("Отмена") }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
sealed class MessageListItem {
|
||||
|
||||
Reference in New Issue
Block a user