remove text from nav

This commit is contained in:
2026-07-29 19:02:12 +03:00
parent ab14a86305
commit 70764a06d1
2 changed files with 27 additions and 30 deletions
@@ -20,9 +20,9 @@ import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.ClickableText
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
@@ -41,12 +41,14 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextLinkStyles
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.text.withLink
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.stringResource
@@ -198,42 +200,40 @@ private fun MessageBubble(
val contentColor = if (isUser) MaterialTheme.colorScheme.onPrimaryContainer else MaterialTheme.colorScheme.onSurfaceVariant
val tokens = remember(message.content) { onParseMessage(message.content) }
val annotatedString = buildAnnotatedString {
tokens.forEachIndexed { index, token ->
tokens.forEach { token ->
when (token) {
is TextToken.Plain -> { append(token.text) }
is TextToken.Link -> {
pushStringAnnotation(tag = "LINK_INDEX", annotation = index.toString())
withStyle(
style = SpanStyle(
color = MaterialTheme.colorScheme.primary,
fontWeight = FontWeight.Bold,
textDecoration = TextDecoration.Underline
)
) { append(token.text) }
pop()
val linkAnnotation = LinkAnnotation.Clickable(
tag = "LINK",
styles = TextLinkStyles(
style = SpanStyle(
color = MaterialTheme.colorScheme.primary,
fontWeight = FontWeight.Bold,
textDecoration = TextDecoration.Underline
)
),
linkInteractionListener = {
onClickLink(token.text)
}
)
withLink(linkAnnotation) { append(token.text) }
}
}
}
}
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = alignment) {
Card(
colors = CardDefaults.cardColors(containerColor = containerColor, contentColor = contentColor),
modifier = Modifier.widthIn(max = 280.dp)
) {
Column(modifier = Modifier.padding(12.dp)) {
ClickableText(
text = annotatedString,
style = MaterialTheme.typography.bodyLarge.copy(color = contentColor),
onClick = { offset ->
annotatedString.getStringAnnotations(tag = "LINK_INDEX", start = offset, end = offset)
.firstOrNull()?.let { annotation ->
val tokenIndex = annotation.item.toIntOrNull() ?: return@ClickableText
val clickedToken = tokens.getOrNull(tokenIndex) as? TextToken.Link ?: return@ClickableText
onClickLink(clickedToken.text)
}
}
)
SelectionContainer {
Text(
text = annotatedString,
style = MaterialTheme.typography.bodyLarge.copy(color = contentColor)
)
}
}
}
}