From 4278101c19874fc44b04b570dba04f0ab508b346 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 18 Jul 2025 18:19:45 +0400 Subject: [PATCH] copy --- .../simplex/common/views/chat/ChatView.kt | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt index 0d04bb5101..4f755d52f8 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/ChatView.kt @@ -1794,6 +1794,12 @@ fun BoxScope.ChatItemsList( } } + val clipboard = LocalClipboardManager.current + val copyNameToClipboard = fun (name: String) { + clipboard.setText(AnnotatedString(name)) + showToast(generalGetString(MR.strings.copied)) + } + Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier @@ -1815,6 +1821,7 @@ fun BoxScope.ChatItemsList( ) { ChatInfoImage(chatInfo, size = 96.dp) + val copyDisplayName = { copyNameToClipboard(chatInfo.displayName) } Text( chatInfo.displayName, style = MaterialTheme.typography.h3, @@ -1822,11 +1829,15 @@ fun BoxScope.ChatItemsList( textAlign = TextAlign.Center, maxLines = 2, overflow = TextOverflow.Ellipsis, - modifier = Modifier.widthIn(max = 240.dp) + modifier = Modifier + .widthIn(max = 240.dp) + .combinedClickable(onClick = copyDisplayName, onLongClick = copyDisplayName) + .onRightClick(copyDisplayName) ) val fullName = chatInfo.fullName.trim() if (fullName.isNotEmpty() && fullName != chatInfo.displayName && fullName != chatInfo.displayName.trim()) { + val copyFullName = { copyNameToClipboard(fullName) } Text( fullName, style = MaterialTheme.typography.h4, @@ -1834,12 +1845,16 @@ fun BoxScope.ChatItemsList( textAlign = TextAlign.Center, maxLines = 3, overflow = TextOverflow.Ellipsis, - modifier = Modifier.widthIn(max = 260.dp) + modifier = Modifier + .widthIn(max = 260.dp) + .combinedClickable(onClick = copyFullName, onLongClick = copyFullName) + .onRightClick(copyFullName) ) } val descr = chatInfo.shortDescr?.trim() if (descr != null && descr != "") { + val copyDescr = { copyNameToClipboard(descr) } Text( descr, style = MaterialTheme.typography.body2, @@ -1847,7 +1862,10 @@ fun BoxScope.ChatItemsList( textAlign = TextAlign.Center, maxLines = 4, overflow = TextOverflow.Ellipsis, - lineHeight = 21.sp + lineHeight = 21.sp, + modifier = Modifier + .combinedClickable(onClick = copyDescr, onLongClick = copyDescr) + .onRightClick(copyDescr) ) }