Compare commits

...

8 Commits

Author SHA1 Message Date
Jesse Horne
ff201f4dd7 gave back original swipe modifier default 2023-11-28 14:08:07 -05:00
Jesse Horne
0b30ae02ff removed some repetition 2023-11-28 14:06:13 -05:00
Jesse Horne
ce7300b4bb removed some repetition 2023-11-28 14:02:15 -05:00
Jesse Horne
ff3ad7487c reverted swipe modifier to original 2023-11-28 13:57:46 -05:00
Jesse Horne
64662435e2 removed useless new line 2023-11-28 12:21:08 -05:00
Jesse Horne
bdf3eb6a83 fixed showmenu for main chat item 2023-11-28 12:11:43 -05:00
Jesse Horne
a712caf07c Merge branch 'master' into jh/desktop-select-text-with-cursor 2023-11-28 11:54:07 -05:00
Jesse Horne
7c1f8d6a4c initial work on selecting text in desktop 2023-11-27 20:02:17 -05:00
3 changed files with 52 additions and 9 deletions

View File

@@ -124,7 +124,7 @@ fun ChatItemView(
Column(
Modifier
.clip(RoundedCornerShape(18.dp))
.combinedClickable(onLongClick = { showMenu.value = true }, onClick = onClick)
.combinedClickable(onLongClick = { if (!appPlatform.isDesktop) showMenu.value = true }, onClick = onClick)
.onRightClick { showMenu.value = true },
) {
@Composable

View File

@@ -3,6 +3,7 @@ package chat.simplex.common.views.chat.item
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@@ -11,6 +12,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.input.pointer.PointerButton
import androidx.compose.ui.layout.*
import androidx.compose.ui.platform.UriHandler
import dev.icerock.moko.resources.compose.painterResource
@@ -50,7 +52,7 @@ fun FramedItemView(
fun Color.toQuote(): Color = if (isInDarkTheme()) lighter(0.12f) else darker(0.12f)
@Composable
fun ciQuotedMsgTextView(qi: CIQuote, lines: Int) {
fun ciQuotedMsgTextViewMarkdown(qi: CIQuote, lines: Int) {
MarkdownText(
qi.text,
qi.formattedText,
@@ -62,6 +64,22 @@ fun FramedItemView(
)
}
@Composable
fun ciQuotedMsgTextView(qi: CIQuote, lines: Int) {
if (appPlatform.isDesktop) {
SelectionContainer(
modifier = Modifier.onClick(
matcher = PointerMatcher.mouse(PointerButton.Secondary),
onClick = { showMenu.value = true }
)
) {
ciQuotedMsgTextViewMarkdown(qi, lines)
}
} else {
ciQuotedMsgTextViewMarkdown(qi, lines)
}
}
@Composable
fun ciQuotedMsgView(qi: CIQuote) {
Box(
@@ -265,7 +283,7 @@ fun FramedItemView(
CIMarkdownText(ci, chatTTL, linkMode, uriHandler, onLinkLongClick)
}
}
else -> CIMarkdownText(ci, chatTTL, linkMode, uriHandler, onLinkLongClick)
else -> CIMarkdownText(ci, chatTTL, linkMode, uriHandler, onLinkLongClick, showMenu = showMenu)
}
}
}
@@ -278,20 +296,44 @@ fun FramedItemView(
}
@Composable
fun CIMarkdownText(
fun CIMarkdownTextMarkdown(
text: String,
ci: ChatItem,
chatTTL: Int?,
linkMode: SimplexLinkMode,
uriHandler: UriHandler?,
onLinkLongClick: (link: String) -> Unit = {}
) {
MarkdownText(
text, if (text.isEmpty()) emptyList() else ci.formattedText,
meta = ci.meta, chatTTL = chatTTL, linkMode = linkMode,
uriHandler = uriHandler, senderBold = true, onLinkLongClick = onLinkLongClick
)
}
@Composable
fun CIMarkdownText(
ci: ChatItem,
chatTTL: Int?,
linkMode: SimplexLinkMode,
uriHandler: UriHandler?,
onLinkLongClick: (link: String) -> Unit = {},
showMenu: MutableState<Boolean> = mutableStateOf(false)
) {
Box(Modifier.padding(vertical = 6.dp, horizontal = 12.dp)) {
val text = if (ci.meta.isLive) ci.content.msgContent?.text ?: ci.text else ci.text
MarkdownText(
text, if (text.isEmpty()) emptyList() else ci.formattedText,
meta = ci.meta, chatTTL = chatTTL, linkMode = linkMode,
uriHandler = uriHandler, senderBold = true, onLinkLongClick = onLinkLongClick
)
if (appPlatform.isDesktop) {
SelectionContainer(
modifier = Modifier.onClick(
matcher = PointerMatcher.mouse(PointerButton.Secondary),
onClick = { showMenu.value = true }
)
) {
CIMarkdownTextMarkdown(text, ci, chatTTL, linkMode, uriHandler, onLinkLongClick)
}
} else {
CIMarkdownTextMarkdown(text, ci, chatTTL, linkMode, uriHandler, onLinkLongClick)
}
}
}

View File

@@ -42,3 +42,4 @@ fun SwipeToDismissModifier(
reverseDirection = isRtl,
).offset { IntOffset(state.offset.value.roundToInt(), 0) }
}