From 85e7a13dba593a8a3ca4680ecfef97d31c1c5c6a Mon Sep 17 00:00:00 2001 From: Diogo Date: Tue, 3 Dec 2024 12:26:50 +0000 Subject: [PATCH] desktop: show group message reaction on right click (#5304) * desktop: show group message reaction on right click * open on ctrl + click too --- .../common/views/chat/item/ChatItemView.kt | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt index 82744fdc39..bf871ab626 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt @@ -121,9 +121,33 @@ fun ChatItemView( cItem.reactions.forEach { r -> val showReactionMenu = remember { mutableStateOf(false) } val reactionMembers = remember { mutableStateOf(emptyList()) } + val interactionSource = remember { MutableInteractionSource() } + val enterInteraction = remember { HoverInteraction.Enter() } + KeyChangeEffect(highlighted.value) { + if (highlighted.value) { + interactionSource.emit(enterInteraction) + } else { + interactionSource.emit(HoverInteraction.Exit(enterInteraction)) + } + } var modifier = Modifier.padding(horizontal = 5.dp, vertical = 2.dp).clip(RoundedCornerShape(8.dp)) if (cInfo.featureEnabled(ChatFeature.Reactions)) { + fun showReactionsMenu() { + if (cInfo is ChatInfo.Group) { + withBGApi { + try { + val members = controller.apiGetReactionMembers(rhId, cInfo.groupInfo.groupId, cItem.id, r.reaction) + if (members != null) { + showReactionMenu.value = true + reactionMembers.value = members + } + } catch (e: Exception) { + Log.d(TAG, "hatItemView ChatItemReactions onLongClick: unexpected exception: ${e.stackTraceToString()}") + } + } + } + } modifier = modifier .combinedClickable( onClick = { @@ -132,21 +156,12 @@ fun ChatItemView( } }, onLongClick = { - if (cInfo is ChatInfo.Group) { - withBGApi { - try { - val members = controller.apiGetReactionMembers(rhId, cInfo.groupInfo.groupId, cItem.id, r.reaction) - if (members != null) { - showReactionMenu.value = true - reactionMembers.value = members - } - } catch (e: Exception) { - Log.d(TAG, "hatItemView ChatItemReactions onLongClick: unexpected exception: ${e.stackTraceToString()}") - } - } - } - } + showReactionsMenu() + }, + interactionSource = interactionSource, + indication = LocalIndication.current ) + .onRightClick { showReactionsMenu() } } Row(modifier.padding(2.dp), verticalAlignment = Alignment.CenterVertically) { ReactionIcon(r.reaction.text, fontSize = 12.sp)