From 14d7fc6eb10706adb1f326bc9d7e65533d282039 Mon Sep 17 00:00:00 2001 From: k1ngsterr1 Date: Wed, 8 Apr 2026 00:50:25 +0500 Subject: [PATCH] =?UTF-8?q?Forward:=20=D1=84=D0=B8=D0=BA=D1=81=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=B0=20=D0=BF=D1=83=D0=B7=D1=8B?= =?UTF-8?q?=D1=80=D1=8F=20=D0=B8=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8.=20=D0=94=D1=83=D0=B1=D0=BB=D0=B8=20=D0=B4=D0=B0?= =?UTF-8?q?=D1=82=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Forward пузырь подстраивается под размер контента (как Telegram) - Длинные имена обрезаются "Forwarded from Alex M..." вместо растяжения - Исправлена отправка forward — consumeForwardMessagesForChat при открытии чата - Floating date header показывается только при активном скролле (убраны дубли дат) Co-Authored-By: Claude Opus 4.6 (1M context) --- .../messenger/ui/chats/ChatDetailScreen.kt | 11 ++++- .../chats/components/ChatDetailComponents.kt | 49 +++++++++---------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt index 5c70100..1031d06 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/ChatDetailScreen.kt @@ -1388,6 +1388,14 @@ fun ChatDetailScreen( com.rosetta.messenger.ui.components.EmojiCache.preload(context) } + // Consume pending forward messages for this chat + LaunchedEffect(user.publicKey, forwardTrigger) { + val pendingForwards = ForwardManager.consumeForwardMessagesForChat(user.publicKey) + if (pendingForwards.isNotEmpty()) { + viewModel.sendForwardDirectly(user.publicKey, pendingForwards) + } + } + // Отмечаем сообщения как прочитанные только когда экран активен (RESUMED) LaunchedEffect(messages, isScreenActive) { if (messages.isNotEmpty() && isScreenActive) { @@ -1440,8 +1448,7 @@ fun ChatDetailScreen( messagesWithDates.isNotEmpty() && floatingDateText != null && !isAtBottom && - (listState.isScrollInProgress || - listState.firstVisibleItemIndex > 0) + listState.isScrollInProgress } } diff --git a/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt b/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt index 40f2ee4..65f9bf5 100644 --- a/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt +++ b/app/src/main/java/com/rosetta/messenger/ui/chats/components/ChatDetailComponents.kt @@ -2383,6 +2383,7 @@ fun ForwardedMessagesBubble( onMentionClick: (username: String) -> Unit = {}, onTextSpanPressStart: (() -> Unit)? = null ) { + val configuration = androidx.compose.ui.platform.LocalConfiguration.current val backgroundColor = if (isOutgoing) Color.Black.copy(alpha = 0.1f) else Color.Black.copy(alpha = 0.05f) @@ -2406,9 +2407,11 @@ fun ForwardedMessagesBubble( }.toMap() } + val maxBubbleWidth = (configuration.screenWidthDp * 0.65f).dp + Column( modifier = Modifier - .fillMaxWidth() + .widthIn(max = maxBubbleWidth) .clip(RoundedCornerShape(4.dp)) .background(backgroundColor) ) { @@ -2439,29 +2442,24 @@ fun ForwardedMessagesBubble( } // "Forwarded from [Name]" — clickable to open profile - Row( - verticalAlignment = Alignment.CenterVertically, + Text( + text = buildAnnotatedString { + withStyle(SpanStyle( + color = nameColor.copy(alpha = 0.7f), + fontWeight = FontWeight.Normal + )) { append("Forwarded from ") } + withStyle(SpanStyle( + color = nameColor, + fontWeight = FontWeight.Bold + )) { append(fwd.forwardedFromName.ifEmpty { "User" }) } + }, + fontSize = 13.sp, + maxLines = 1, + overflow = TextOverflow.Ellipsis, modifier = Modifier.clickable(enabled = fwd.senderPublicKey.isNotEmpty()) { onForwardedSenderClick(fwd.senderPublicKey) } - ) { - Text( - text = "Forwarded from ", - color = nameColor.copy(alpha = 0.7f), - fontSize = 13.sp, - fontWeight = FontWeight.Normal, - maxLines = 1 - ) - Text( - text = fwd.forwardedFromName.ifEmpty { "User" }, - color = nameColor, - fontSize = 13.sp, - fontWeight = FontWeight.Bold, - maxLines = 1, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.weight(1f, fill = false) - ) - } + ) // Attachments (images) — before text (text acts as caption) val imageAttachments = fwd.attachments.filter { it.type == AttachmentType.IMAGE } @@ -2611,10 +2609,11 @@ private fun ForwardedImagePreview( } } - val maxPhotoWidthDp = TelegramBubbleSpec.maxPhotoWidth(configuration.screenWidthDp).dp - val minPhotoWidthDp = TelegramBubbleSpec.minPhotoWidth.dp - val minPhotoHeightDp = TelegramBubbleSpec.minPhotoHeight.dp - val maxPhotoHeightDp = TelegramBubbleSpec.maxPhotoHeight.dp + // Forwarded images use smaller max size to fit inside the forward bubble + val maxPhotoWidthDp = (configuration.screenWidthDp * 0.55f).toInt().dp + val minPhotoWidthDp = 100.dp + val minPhotoHeightDp = 80.dp + val maxPhotoHeightDp = 280.dp val (previewWidth, previewHeight) = remember( attachment.width,