diff --git a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationMessageItemView.kt b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationMessageItemView.kt index 1bb873d71eb6d4629c3336619c046de2aa118037..6d7ad7f27d932768c2a4e10cc9a5df848923ae04 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationMessageItemView.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationMessageItemView.kt @@ -21,6 +21,7 @@ package org.briarproject.briar.desktop.conversation import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -78,12 +79,14 @@ fun ConversationMessageItemView( } } if (m.text != null) { - Text( - m.text!!, - fontSize = 16.sp, - color = textColor, - modifier = Modifier.align(Alignment.Start).padding(bottom = 8.dp) - ) + SelectionContainer { + Text( + m.text!!, + fontSize = 16.sp, + color = textColor, + modifier = Modifier.align(Alignment.Start).padding(bottom = 8.dp) + ) + } } ConversationItemStatusView(m) } diff --git a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationNoticeItemView.kt b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationNoticeItemView.kt index 9ab2ebac87a333b4c5ec38ef6af0a04bb8ec408d..f6ef3e063d652076b2aac15a932adb56be64bf0a 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationNoticeItemView.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationNoticeItemView.kt @@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.IntrinsicSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width +import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -84,12 +85,14 @@ fun ConversationNoticeItemView( ConversationItemView(m, onDelete) { Column(Modifier.width(IntrinsicSize.Max)) { if (text != null) { - Text( - text, - fontSize = 16.sp, - color = textColor, - modifier = Modifier.padding(12.dp, 8.dp).align(Alignment.Start) - ) + SelectionContainer { + Text( + text, + fontSize = 16.sp, + color = textColor, + modifier = Modifier.padding(12.dp, 8.dp).align(Alignment.Start) + ) + } } Column( Modifier.fillMaxWidth().background(noticeBackground).padding(12.dp, 8.dp) diff --git a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt index 00e448f28c8f224316545d401ae2b1a80f9d9b5e..1705fd12f96ce2e56e519092e0abb2b3c5642f76 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationRequestItemView.kt @@ -27,6 +27,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width +import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.material.ButtonType.DESTRUCTIVE import androidx.compose.material.ButtonType.NEUTRAL import androidx.compose.material.DialogButton @@ -102,12 +103,14 @@ fun ConversationRequestItemView( Column(Modifier.width(IntrinsicSize.Max)) { val text = m.text if (text != null) { - Text( - text, - fontSize = 16.sp, - color = textColor, - modifier = Modifier.padding(12.dp, 8.dp).align(Alignment.Start) - ) + SelectionContainer { + Text( + text, + fontSize = 16.sp, + color = textColor, + modifier = Modifier.padding(12.dp, 8.dp).align(Alignment.Start) + ) + } } Column( Modifier.fillMaxWidth().background(noticeBackground).padding(12.dp, 8.dp) diff --git a/src/main/kotlin/org/briarproject/briar/desktop/theme/Theme.kt b/src/main/kotlin/org/briarproject/briar/desktop/theme/Theme.kt index 1f2f74cfefaf0358b416333fb040bdb64a2c6a66..eb11d0c35fc1d317bfd3eceac0e2b1f3461a12db 100644 --- a/src/main/kotlin/org/briarproject/briar/desktop/theme/Theme.kt +++ b/src/main/kotlin/org/briarproject/briar/desktop/theme/Theme.kt @@ -19,11 +19,14 @@ package org.briarproject.briar.desktop.theme import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.text.selection.LocalTextSelectionColors +import androidx.compose.foundation.text.selection.TextSelectionColors import androidx.compose.material.Colors import androidx.compose.material.MaterialTheme import androidx.compose.material.darkColors import androidx.compose.material.lightColors import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.graphics.Color val Colors.divider: Color get() = if (isLight) Gray300 else Gray800 @@ -77,8 +80,14 @@ fun BriarTheme( ) { val myColors = colors ?: if (isDarkTheme) DarkColors else LightColors - MaterialTheme( - colors = myColors, - content = content, - ) + MaterialTheme(myColors) { + val customTextSelectionColors = TextSelectionColors( + handleColor = MaterialTheme.colors.secondary, + backgroundColor = MaterialTheme.colors.secondary.copy(alpha = 0.4f) + ) + + CompositionLocalProvider(LocalTextSelectionColors provides customTextSelectionColors) { + content() + } + } }