mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff201f4dd7 | |||
| 0b30ae02ff | |||
| ce7300b4bb | |||
| ff3ad7487c | |||
| 64662435e2 | |||
| bdf3eb6a83 | |||
| a712caf07c | |||
| 7c1f8d6a4c |
+1
-1
@@ -124,7 +124,7 @@ fun ChatItemView(
|
|||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
.clip(RoundedCornerShape(18.dp))
|
.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 },
|
.onRightClick { showMenu.value = true },
|
||||||
) {
|
) {
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
+50
-8
@@ -3,6 +3,7 @@ package chat.simplex.common.views.chat.item
|
|||||||
import androidx.compose.foundation.*
|
import androidx.compose.foundation.*
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||||
import androidx.compose.material.*
|
import androidx.compose.material.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Alignment
|
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.draw.clipToBounds
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.painter.Painter
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
|
import androidx.compose.ui.input.pointer.PointerButton
|
||||||
import androidx.compose.ui.layout.*
|
import androidx.compose.ui.layout.*
|
||||||
import androidx.compose.ui.platform.UriHandler
|
import androidx.compose.ui.platform.UriHandler
|
||||||
import dev.icerock.moko.resources.compose.painterResource
|
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)
|
fun Color.toQuote(): Color = if (isInDarkTheme()) lighter(0.12f) else darker(0.12f)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ciQuotedMsgTextView(qi: CIQuote, lines: Int) {
|
fun ciQuotedMsgTextViewMarkdown(qi: CIQuote, lines: Int) {
|
||||||
MarkdownText(
|
MarkdownText(
|
||||||
qi.text,
|
qi.text,
|
||||||
qi.formattedText,
|
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
|
@Composable
|
||||||
fun ciQuotedMsgView(qi: CIQuote) {
|
fun ciQuotedMsgView(qi: CIQuote) {
|
||||||
Box(
|
Box(
|
||||||
@@ -265,7 +283,7 @@ fun FramedItemView(
|
|||||||
CIMarkdownText(ci, chatTTL, linkMode, uriHandler, onLinkLongClick)
|
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
|
@Composable
|
||||||
fun CIMarkdownText(
|
fun CIMarkdownTextMarkdown(
|
||||||
|
text: String,
|
||||||
ci: ChatItem,
|
ci: ChatItem,
|
||||||
chatTTL: Int?,
|
chatTTL: Int?,
|
||||||
linkMode: SimplexLinkMode,
|
linkMode: SimplexLinkMode,
|
||||||
uriHandler: UriHandler?,
|
uriHandler: UriHandler?,
|
||||||
onLinkLongClick: (link: String) -> Unit = {}
|
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)) {
|
Box(Modifier.padding(vertical = 6.dp, horizontal = 12.dp)) {
|
||||||
val text = if (ci.meta.isLive) ci.content.msgContent?.text ?: ci.text else ci.text
|
val text = if (ci.meta.isLive) ci.content.msgContent?.text ?: ci.text else ci.text
|
||||||
MarkdownText(
|
if (appPlatform.isDesktop) {
|
||||||
text, if (text.isEmpty()) emptyList() else ci.formattedText,
|
SelectionContainer(
|
||||||
meta = ci.meta, chatTTL = chatTTL, linkMode = linkMode,
|
modifier = Modifier.onClick(
|
||||||
uriHandler = uriHandler, senderBold = true, onLinkLongClick = onLinkLongClick
|
matcher = PointerMatcher.mouse(PointerButton.Secondary),
|
||||||
)
|
onClick = { showMenu.value = true }
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
CIMarkdownTextMarkdown(text, ci, chatTTL, linkMode, uriHandler, onLinkLongClick)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CIMarkdownTextMarkdown(text, ci, chatTTL, linkMode, uriHandler, onLinkLongClick)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -42,3 +42,4 @@ fun SwipeToDismissModifier(
|
|||||||
reverseDirection = isRtl,
|
reverseDirection = isRtl,
|
||||||
).offset { IntOffset(state.offset.value.roundToInt(), 0) }
|
).offset { IntOffset(state.offset.value.roundToInt(), 0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user