feat: enhance forwarded messages display by enabling link support

This commit is contained in:
2026-02-12 08:15:11 +05:00
parent 6f195f4d09
commit f7ece6055e
7 changed files with 564 additions and 214 deletions

View File

@@ -102,6 +102,7 @@ fun ChatDetailScreen(
onUserProfileClick: (SearchUser) -> Unit = {},
currentUserPublicKey: String,
currentUserPrivateKey: String,
currentUserName: String = "",
totalUnreadFromOthers: Int = 0,
isDarkTheme: Boolean,
avatarRepository: AvatarRepository? = null,
@@ -1369,46 +1370,86 @@ fun ChatDetailScreen(
val forwardMessages =
selectedMsgs
.map {
.flatMap {
msg
->
ForwardManager
.ForwardMessage(
messageId =
msg.id,
text =
msg.text,
timestamp =
msg.timestamp
.time,
isOutgoing =
msg.isOutgoing,
senderPublicKey =
if (msg.isOutgoing
// Re-forward: preserve original senders
if (msg.forwardedMessages.isNotEmpty()) {
msg.forwardedMessages.map { fwd ->
ForwardManager
.ForwardMessage(
messageId =
fwd.messageId,
text =
fwd.text,
timestamp =
msg.timestamp
.time,
isOutgoing =
fwd.isFromMe,
senderPublicKey =
fwd.senderPublicKey.ifEmpty {
if (fwd.isFromMe) currentUserPublicKey else user.publicKey
},
originalChatPublicKey =
user.publicKey,
senderName =
fwd.forwardedFromName.ifEmpty { fwd.senderName.ifEmpty { "User" } },
attachments =
fwd.attachments
.filter {
it.type !=
AttachmentType
.MESSAGES
}
.map {
attachment ->
attachment.copy(
localUri =
""
)
}
)
currentUserPublicKey
else
}
} else {
listOf(ForwardManager
.ForwardMessage(
messageId =
msg.id,
text =
msg.text,
timestamp =
msg.timestamp
.time,
isOutgoing =
msg.isOutgoing,
senderPublicKey =
if (msg.isOutgoing
)
currentUserPublicKey
else
user.publicKey,
originalChatPublicKey =
user.publicKey,
originalChatPublicKey =
user.publicKey,
senderName =
if (msg.isOutgoing) "You"
else user.title.ifEmpty { user.username.ifEmpty { "User" } },
attachments =
msg.attachments
.filter {
it.type !=
AttachmentType
.MESSAGES
}
.map {
attachment ->
attachment.copy(
localUri =
""
)
}
)
senderName =
if (msg.isOutgoing) currentUserName.ifEmpty { "You" }
else user.title.ifEmpty { user.username.ifEmpty { "User" } },
attachments =
msg.attachments
.filter {
it.type !=
AttachmentType
.MESSAGES
}
.map {
attachment ->
attachment.copy(
localUri =
""
)
}
))
}
}
ForwardManager
.setForwardMessages(
@@ -1965,6 +2006,15 @@ fun ChatDetailScreen(
onImageViewerChanged(
true
)
},
onForwardedSenderClick = { senderPublicKey ->
// Open profile of the forwarded message sender
scope.launch {
val resolvedUser = viewModel.resolveUserForProfile(senderPublicKey)
if (resolvedUser != null) {
onUserProfileClick(resolvedUser)
}
}
}
)
}

View File

@@ -1299,7 +1299,25 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val senderDisplayName = fwdSenderName.ifEmpty {
if (fwdIsFromMe) "You"
else opponentTitle.ifEmpty { opponentUsername.ifEmpty { "User" } }
else if (fwdPublicKey.isNotEmpty()) {
// 1. Try local DB (existing dialog)
val dbName = try {
val dialog = dialogDao.getDialog(account, fwdPublicKey)
dialog?.opponentTitle?.ifEmpty { dialog.opponentUsername }?.ifEmpty { null }
} catch (_: Exception) { null }
// 2. Try ProtocolManager cache (previously resolved)
val cachedName = dbName ?: ProtocolManager.getCachedUserName(fwdPublicKey)
// 3. Server resolve via PacketSearch (like desktop useUserInformation)
val serverName = if (cachedName == null) {
try {
ProtocolManager.resolveUserName(fwdPublicKey, 3000)
} catch (_: Exception) { null }
} else null
cachedName ?: serverName ?: "User"
} else "User"
}
forwardedList.add(ReplyData(
@@ -1310,7 +1328,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
isForwarded = true,
forwardedFromName = senderDisplayName,
attachments = fwdAttachments,
senderPublicKey = if (fwdIsFromMe) myPublicKey ?: "" else opponentKey ?: "",
senderPublicKey = fwdPublicKey.ifEmpty { if (fwdIsFromMe) myPublicKey ?: "" else opponentKey ?: "" },
recipientPrivateKey = myPrivateKey ?: ""
))
}
@@ -1326,9 +1344,16 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val replyText = replyMessage.optString("message", "")
val replyMessageIdFromJson = replyMessage.optString("message_id", "")
val replyTimestamp = replyMessage.optLong("timestamp", 0L)
val isForwarded = replyMessage.optBoolean("forwarded", false)
val senderNameFromJson = replyMessage.optString("senderName", "")
// 🔥 Detect forward: explicit flag OR publicKey belongs to a third party
// Desktop doesn't send "forwarded" flag, but if publicKey differs from
// both myPublicKey and opponentKey — it's a forwarded message from someone else
val isFromThirdParty = replyPublicKey.isNotEmpty() &&
replyPublicKey != myPublicKey &&
replyPublicKey != opponentKey
val isForwarded = replyMessage.optBoolean("forwarded", false) || isFromThirdParty
// 📸 Парсим attachments из JSON reply (как в Desktop)
val replyAttachmentsFromJson = mutableListOf<MessageAttachment>()
try {
@@ -1410,28 +1435,62 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
}
}
// 🔥 Resolve sender name by publicKey (like desktop useUserInformation)
// Always resolve from replyPublicKey, not hardcode opponentTitle
val resolvedSenderName = if (isReplyFromMe) {
"You"
} else if (replyPublicKey == opponentKey) {
// Reply to opponent's message in this chat — use known opponent info
opponentTitle.ifEmpty { opponentUsername.ifEmpty { "User" } }
} else if (replyPublicKey.isNotEmpty()) {
// Third-party publicKey — resolve like desktop useUserInformation
senderNameFromJson.ifEmpty {
// 1. Try local DB (existing dialog with this user)
val dbName = try {
val fwdDialog = dialogDao.getDialog(account, replyPublicKey)
fwdDialog?.opponentTitle?.ifEmpty { fwdDialog.opponentUsername }?.ifEmpty { null }
} catch (_: Exception) { null }
// 2. Try ProtocolManager cache
val cachedName = dbName ?: ProtocolManager.getCachedUserName(replyPublicKey)
// 3. Server resolve via PacketSearch (like desktop useUserInformation)
val serverName = if (cachedName == null) {
try {
ProtocolManager.resolveUserName(replyPublicKey, 3000)
} catch (_: Exception) { null }
} else null
cachedName ?: serverName ?: "User"
}
} else {
senderNameFromJson.ifEmpty { "User" }
}
// For forwarded messages, determine the forwardedFromName
val forwardFromDisplay = if (isForwarded) resolvedSenderName else ""
val result =
ReplyData(
messageId = realMessageId,
senderName =
if (isReplyFromMe) "You"
else
opponentTitle.ifEmpty {
opponentUsername.ifEmpty { "User" }
},
senderName = resolvedSenderName,
text = replyText,
isFromMe = isReplyFromMe,
isForwarded = isForwarded,
forwardedFromName = if (isForwarded) senderNameFromJson.ifEmpty {
if (isReplyFromMe) "You"
else opponentTitle.ifEmpty { opponentUsername.ifEmpty { "User" } }
} else "",
forwardedFromName = forwardFromDisplay,
attachments = originalAttachments,
senderPublicKey =
senderPublicKey = replyPublicKey.ifEmpty {
if (isReplyFromMe) myPublicKey ?: ""
else opponentKey ?: "",
else opponentKey ?: ""
},
recipientPrivateKey = myPrivateKey ?: ""
)
// 🔥 If this is a forwarded message (from third party), return as forwardedMessages list
// so it renders with "Forwarded from" header (like multi-forward)
if (isForwarded) {
return ParsedReplyResult(
replyData = result,
forwardedMessages = listOf(result)
)
}
return ParsedReplyResult(replyData = result)
} else {}
} else {}
@@ -1528,6 +1587,79 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
}
}
/**
* Resolve a publicKey to a SearchUser for profile navigation.
* Tries: local DB → ProtocolManager cache → server resolve.
*/
suspend fun resolveUserForProfile(publicKey: String): SearchUser? {
if (publicKey.isEmpty()) return null
// If it's the current opponent, we already have info
if (publicKey == opponentKey) {
return SearchUser(
title = opponentTitle,
username = opponentUsername,
publicKey = publicKey,
verified = 0,
online = 0
)
}
val account = myPublicKey ?: return null
// 1. Try local DB
try {
val dialog = dialogDao.getDialog(account, publicKey)
if (dialog != null) {
val t = dialog.opponentTitle.ifEmpty { dialog.opponentUsername }
if (t.isNotEmpty()) {
return SearchUser(
title = dialog.opponentTitle,
username = dialog.opponentUsername,
publicKey = publicKey,
verified = 0,
online = 0
)
}
}
} catch (_: Exception) {}
// 2. Try ProtocolManager cache
val cached = ProtocolManager.getCachedUserInfo(publicKey)
if (cached != null) {
return SearchUser(
title = cached.title,
username = cached.username,
publicKey = publicKey,
verified = cached.verified,
online = 0
)
}
// 3. Server resolve
try {
val resolved = ProtocolManager.resolveUserInfo(publicKey, 3000)
if (resolved != null) {
return SearchUser(
title = resolved.title,
username = resolved.username,
publicKey = publicKey,
verified = resolved.verified,
online = 0
)
}
} catch (_: Exception) {}
// 4. Fallback: minimal user info
return SearchUser(
title = "User",
username = "",
publicKey = publicKey,
verified = 0,
online = 0
)
}
/** 🔥 Повторить отправку сообщения (для ошибки) */
fun retryMessage(message: ChatMessage) {
// Удаляем старое сообщение
@@ -1593,26 +1725,24 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {
val replyAttachments =
_messages.value.find { it.id == firstReply.messageId }?.attachments
?: firstReply.attachments.filter { it.type != AttachmentType.MESSAGES }
// 🔥 Use actual senderName from ForwardMessage (preserves real author)
val firstReplySenderName = if (firstReply.isOutgoing) "You"
else firstReply.senderName.ifEmpty {
opponentTitle.ifEmpty { opponentUsername.ifEmpty { "User" } }
}
ReplyData(
messageId = firstReply.messageId,
senderName =
if (firstReply.isOutgoing) "You"
else
opponentTitle.ifEmpty {
opponentUsername.ifEmpty { "User" }
},
senderName = firstReplySenderName,
text = firstReply.text,
isFromMe = firstReply.isOutgoing,
isForwarded = isForward,
forwardedFromName =
if (isForward) firstReply.senderName.ifEmpty {
if (firstReply.isOutgoing) "You"
else opponentTitle.ifEmpty { opponentUsername.ifEmpty { "User" } }
} else "",
if (isForward) firstReplySenderName else "",
attachments = replyAttachments,
senderPublicKey =
senderPublicKey = firstReply.publicKey.ifEmpty {
if (firstReply.isOutgoing) myPublicKey ?: ""
else opponentKey ?: "",
else opponentKey ?: ""
},
recipientPrivateKey = myPrivateKey ?: ""
)
} else null

View File

@@ -260,7 +260,8 @@ fun MessageBubble(
onReplyClick: (String) -> Unit = {},
onRetry: () -> Unit = {},
onDelete: () -> Unit = {},
onImageClick: (attachmentId: String, bounds: ImageSourceBounds?) -> Unit = { _, _ -> }
onImageClick: (attachmentId: String, bounds: ImageSourceBounds?) -> Unit = { _, _ -> },
onForwardedSenderClick: (senderPublicKey: String) -> Unit = {}
) {
// Swipe-to-reply state
var swipeOffset by remember { mutableStateOf(0f) }
@@ -649,7 +650,8 @@ fun MessageBubble(
isDarkTheme = isDarkTheme,
chachaKey = message.chachaKey,
privateKey = privateKey,
onImageClick = onImageClick
onImageClick = onImageClick,
onForwardedSenderClick = onForwardedSenderClick
)
Spacer(modifier = Modifier.height(4.dp))
}
@@ -662,7 +664,8 @@ fun MessageBubble(
chachaKey = message.chachaKey,
privateKey = privateKey,
onClick = { onReplyClick(reply.messageId) },
onImageClick = onImageClick
onImageClick = onImageClick,
onForwardedSenderClick = onForwardedSenderClick
)
Spacer(modifier = Modifier.height(4.dp))
}
@@ -1095,7 +1098,8 @@ fun ReplyBubble(
chachaKey: String = "",
privateKey: String = "",
onClick: () -> Unit = {},
onImageClick: (attachmentId: String, bounds: ImageSourceBounds?) -> Unit = { _, _ -> }
onImageClick: (attachmentId: String, bounds: ImageSourceBounds?) -> Unit = { _, _ -> },
onForwardedSenderClick: (senderPublicKey: String) -> Unit = {}
) {
val context = androidx.compose.ui.platform.LocalContext.current
val backgroundColor =
@@ -1220,32 +1224,24 @@ fun ReplyBubble(
imageAttachment.id, downloadTag
)
if (encryptedContent.isNotEmpty()) {
// Расшифровываем: нужен chachaKey сообщения-контейнера
val keyToUse = chachaKey.ifEmpty { replyData.recipientPrivateKey }
val privKey = privateKey.ifEmpty { replyData.recipientPrivateKey }
// Desktop: decryptKeyFromSender → decodeWithPassword
var decrypted: String? = null
// Способ 1: chachaKey + privateKey → ECDH → decrypt
if (chachaKey.isNotEmpty() && privKey.isNotEmpty()) {
if (chachaKey.isNotEmpty() && privateKey.isNotEmpty()) {
try {
val plainKeyAndNonce = MessageCrypto.decryptKeyFromSender(
chachaKey, privKey
)
decrypted = MessageCrypto.decryptAttachmentBlobWithPlainKey(
encryptedContent, plainKeyAndNonce
)
} catch (_: Exception) {}
}
// Способ 2: senderPublicKey + recipientPrivateKey
if (decrypted == null && replyData.senderPublicKey.isNotEmpty() && replyData.recipientPrivateKey.isNotEmpty()) {
try {
val plainKeyAndNonce = MessageCrypto.decryptKeyFromSender(
replyData.senderPublicKey, replyData.recipientPrivateKey
)
decrypted = MessageCrypto.decryptAttachmentBlobWithPlainKey(
encryptedContent, plainKeyAndNonce
chachaKey, privateKey
)
// decryptReplyBlob = desktop decodeWithPassword
decrypted = try {
MessageCrypto.decryptReplyBlob(encryptedContent, plainKeyAndNonce)
.takeIf { it.isNotEmpty() && it != encryptedContent }
} catch (_: Exception) { null }
if (decrypted == null) {
decrypted = MessageCrypto.decryptAttachmentBlobWithPlainKey(
encryptedContent, plainKeyAndNonce
)
}
} catch (_: Exception) {}
}
@@ -1296,7 +1292,12 @@ fun ReplyBubble(
) {
// Заголовок (имя отправителя / Forwarded from)
if (replyData.isForwarded && replyData.forwardedFromName.isNotEmpty()) {
Row(verticalAlignment = Alignment.CenterVertically) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.clickable(enabled = replyData.senderPublicKey.isNotEmpty()) {
onForwardedSenderClick(replyData.senderPublicKey)
}
) {
Text(
text = "Forwarded from ",
color = nameColor,
@@ -1431,7 +1432,8 @@ fun ForwardedMessagesBubble(
isDarkTheme: Boolean,
chachaKey: String = "",
privateKey: String = "",
onImageClick: (attachmentId: String, bounds: ImageSourceBounds?) -> Unit = { _, _ -> }
onImageClick: (attachmentId: String, bounds: ImageSourceBounds?) -> Unit = { _, _ -> },
onForwardedSenderClick: (senderPublicKey: String) -> Unit = {}
) {
val backgroundColor =
if (isOutgoing) Color.Black.copy(alpha = 0.1f)
@@ -1488,8 +1490,13 @@ fun ForwardedMessagesBubble(
senderColorMap[fwd.forwardedFromName] ?: PrimaryBlue
}
// "Forwarded from [Name]"
Row(verticalAlignment = Alignment.CenterVertically) {
// "Forwarded from [Name]" — clickable to open profile
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.clickable(enabled = fwd.senderPublicKey.isNotEmpty()) {
onForwardedSenderClick(fwd.senderPublicKey)
}
) {
Text(
text = "Forwarded from ",
color = nameColor.copy(alpha = 0.7f),
@@ -1508,22 +1515,7 @@ fun ForwardedMessagesBubble(
)
}
// Message text
if (fwd.text.isNotEmpty()) {
Spacer(modifier = Modifier.height(2.dp))
val textColor = if (isOutgoing) Color.White.copy(alpha = 0.9f)
else if (isDarkTheme) Color.White else Color.Black
AppleEmojiText(
text = fwd.text,
color = textColor,
fontSize = 14.sp,
maxLines = 50,
overflow = android.text.TextUtils.TruncateAt.END,
enableLinks = false
)
}
// Attachments (images)
// Attachments (images) — before text (text acts as caption)
val imageAttachments = fwd.attachments.filter { it.type == AttachmentType.IMAGE }
if (imageAttachments.isNotEmpty()) {
Spacer(modifier = Modifier.height(4.dp))
@@ -1538,13 +1530,28 @@ fun ForwardedMessagesBubble(
)
}
}
// Message text (below image, like a caption)
if (fwd.text.isNotEmpty()) {
Spacer(modifier = Modifier.height(2.dp))
val textColor = if (isOutgoing) Color.White.copy(alpha = 0.9f)
else if (isDarkTheme) Color.White else Color.Black
AppleEmojiText(
text = fwd.text,
color = textColor,
fontSize = 14.sp,
maxLines = 50,
overflow = android.text.TextUtils.TruncateAt.END,
enableLinks = true
)
}
}
}
}
}
}
/** Image preview inside a forwarded message */
/** Image preview inside a forwarded message — decrypts exactly like desktop */
@Composable
private fun ForwardedImagePreview(
attachment: MessageAttachment,
@@ -1555,55 +1562,102 @@ private fun ForwardedImagePreview(
onImageClick: (attachmentId: String, bounds: ImageSourceBounds?) -> Unit
) {
val context = androidx.compose.ui.platform.LocalContext.current
var imageBitmap by remember { mutableStateOf<Bitmap?>(null) }
var blurPreviewBitmap by remember { mutableStateOf<Bitmap?>(null) }
val cacheKey = "img_${attachment.id}"
// Load blur preview first
var imageBitmap by remember(attachment.id) {
mutableStateOf(ImageBitmapCache.get(cacheKey))
}
var blurPreviewBitmap by remember(attachment.id) { mutableStateOf<android.graphics.Bitmap?>(null) }
// Extract CDN tag and blurhash from preview (format: "UUID::blurhash")
val downloadTag = remember(attachment.preview) { getDownloadTag(attachment.preview) }
val blurhashPreview = remember(attachment.preview) { getPreview(attachment.preview) }
// Load blur preview
LaunchedEffect(attachment.id) {
if (attachment.preview.isNotEmpty()) {
try {
val bitmap = BlurHash.decode(attachment.preview, 32, 32)
if (bitmap != null) blurPreviewBitmap = bitmap
} catch (_: Exception) {}
if (blurhashPreview.isNotEmpty()) {
withContext(Dispatchers.IO) {
try {
val bitmap = BlurHash.decode(blurhashPreview, 32, 32)
if (bitmap != null) blurPreviewBitmap = bitmap
} catch (_: Exception) {}
}
}
}
// Decrypt and load full image
// Main image loading — Desktop pipeline:
// 1. decryptKeyFromSender(chachaKey, privateKey) → plainKeyAndNonce
// 2. password = plainKeyAndNonce.toString('utf-8') (bytesToJsUtf8String)
// 3. decodeWithPassword(password, encryptedBlob) = PBKDF2 + AES-CBC + inflate
LaunchedEffect(attachment.id) {
// Skip if already loaded
val cached = ImageBitmapCache.get(cacheKey)
if (cached != null) { imageBitmap = cached; return@LaunchedEffect }
withContext(Dispatchers.IO) {
// Try local file cache first
try {
// Try loading from file cache first
val cached = AttachmentFileManager.readAttachment(
val localBlob = AttachmentFileManager.readAttachment(
context, attachment.id, senderPublicKey, recipientPrivateKey
)
if (cached != null) {
val bytes = Base64.decode(cached, Base64.DEFAULT)
BitmapFactory.decodeByteArray(bytes, 0, bytes.size)?.let {
imageBitmap = it
if (localBlob != null) {
val bitmap = base64ToBitmap(localBlob)
if (bitmap != null) {
imageBitmap = bitmap
ImageBitmapCache.put(cacheKey, bitmap)
return@withContext
}
}
} catch (_: Exception) {}
// Try decrypting from blob
if (attachment.blob.isNotEmpty()) {
val keyToUse = chachaKey.ifEmpty { recipientPrivateKey }
val privKey = privateKey.ifEmpty { recipientPrivateKey }
val decrypted = MessageCrypto.decryptAttachmentBlob(
attachment.blob, keyToUse, privKey
)
if (decrypted != null) {
val bytes = Base64.decode(decrypted, Base64.DEFAULT)
BitmapFactory.decodeByteArray(bytes, 0, bytes.size)?.let {
imageBitmap = it
ImageBitmapCache.put("img_${attachment.id}", it)
AttachmentFileManager.saveAttachment(
context, decrypted, attachment.id,
senderPublicKey, recipientPrivateKey
)
// CDN download — exactly like desktop useAttachment.ts
if (downloadTag.isNotEmpty() && chachaKey.isNotEmpty() && privateKey.isNotEmpty()) {
try {
val encryptedContent = TransportManager.downloadFile(attachment.id, downloadTag)
if (encryptedContent.isNotEmpty()) {
// Desktop: decryptKeyFromSender → plainKeyAndNonce → decodeWithPassword
val plainKeyAndNonce = MessageCrypto.decryptKeyFromSender(chachaKey, privateKey)
// decryptReplyBlob = exact same as desktop decodeWithPassword:
// bytesToJsUtf8String(plainKeyAndNonce) → PBKDF2(password,'rosetta',SHA256,1000) → AES-CBC → inflate
val decrypted = MessageCrypto.decryptReplyBlob(encryptedContent, plainKeyAndNonce)
if (decrypted.isNotEmpty() && decrypted != encryptedContent) {
val base64Data = if (decrypted.contains(",")) decrypted.substringAfter(",") else decrypted
val bitmap = base64ToBitmap(base64Data)
if (bitmap != null) {
imageBitmap = bitmap
ImageBitmapCache.put(cacheKey, bitmap)
AttachmentFileManager.saveAttachment(
context, base64Data, attachment.id,
senderPublicKey, recipientPrivateKey
)
return@withContext
}
}
// Fallback: try decryptAttachmentBlobWithPlainKey (same logic, different entry point)
val decrypted2 = MessageCrypto.decryptAttachmentBlobWithPlainKey(encryptedContent, plainKeyAndNonce)
if (decrypted2 != null) {
val base64Data = if (decrypted2.contains(",")) decrypted2.substringAfter(",") else decrypted2
val bitmap = base64ToBitmap(base64Data)
if (bitmap != null) {
imageBitmap = bitmap
ImageBitmapCache.put(cacheKey, bitmap)
AttachmentFileManager.saveAttachment(
context, base64Data, attachment.id,
senderPublicKey, recipientPrivateKey
)
}
}
}
}
} catch (_: Exception) {}
} catch (_: Exception) {}
}
}
// Retry from cache (another composable may have loaded it)
if (imageBitmap == null) {
repeat(5) {
kotlinx.coroutines.delay(400)
ImageBitmapCache.get(cacheKey)?.let { imageBitmap = it; return@LaunchedEffect }
}
}
}

View File

@@ -172,7 +172,8 @@ fun OtherProfileScreen(
avatarRepository: AvatarRepository? = null,
currentUserPublicKey: String = "",
currentUserPrivateKey: String = "",
backgroundBlurColorId: String = "avatar"
backgroundBlurColorId: String = "avatar",
onWriteMessage: (SearchUser) -> Unit = {}
) {
var isBlocked by remember { mutableStateOf(false) }
var showAvatarMenu by remember { mutableStateOf(false) }
@@ -541,6 +542,47 @@ fun OtherProfileScreen(
Spacer(modifier = Modifier.height(12.dp))
// ═══════════════════════════════════════════════════════════
// ✉️ WRITE MESSAGE BUTTON
// ═══════════════════════════════════════════════════════════
Box(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
) {
Button(
onClick = { onWriteMessage(user) },
modifier = Modifier
.fillMaxWidth()
.height(48.dp),
shape = RoundedCornerShape(12.dp),
colors = ButtonDefaults.buttonColors(
containerColor = PrimaryBlue,
contentColor = Color.White
),
elevation = ButtonDefaults.buttonElevation(
defaultElevation = 0.dp,
pressedElevation = 0.dp
)
) {
Icon(
TablerIcons.MessageCircle2,
contentDescription = null,
modifier = Modifier.size(20.dp),
tint = Color.White
)
Spacer(modifier = Modifier.width(8.dp))
Text(
text = "Write Message",
fontSize = 16.sp,
fontWeight = FontWeight.SemiBold,
color = Color.White
)
}
}
Spacer(modifier = Modifier.height(16.dp))
// ═══════════════════════════════════════════════════════════
// 📚 SHARED CONTENT
// ═══════════════════════════════════════════════════════════