mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 14:07:05 +05:30
fix(common): use a custom link style for legibility
This commit is contained in:
parent
e483ceea5f
commit
1ba9cefda6
1 changed files with 13 additions and 1 deletions
|
@ -6,22 +6,34 @@ import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.SpanStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import com.halilibo.richtext.markdown.Markdown
|
import com.halilibo.richtext.markdown.Markdown
|
||||||
import com.halilibo.richtext.ui.RichText
|
import com.halilibo.richtext.ui.RichText
|
||||||
import com.halilibo.richtext.ui.RichTextStyle
|
import com.halilibo.richtext.ui.RichTextStyle
|
||||||
|
import com.halilibo.richtext.ui.string.RichTextStringStyle
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ThemedRichText(
|
fun ThemedRichText(
|
||||||
text: String,
|
text: String,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
|
val linkStyle =
|
||||||
|
SpanStyle(
|
||||||
|
background = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
textDecoration = TextDecoration.Underline,
|
||||||
|
)
|
||||||
|
val stringStyle = RichTextStringStyle.Default.copy(linkStyle = linkStyle)
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalTextStyle provides MaterialTheme.typography.bodyLarge,
|
LocalTextStyle provides MaterialTheme.typography.bodyLarge,
|
||||||
LocalContentColor provides MaterialTheme.colorScheme.onBackground,
|
LocalContentColor provides MaterialTheme.colorScheme.onBackground,
|
||||||
) {
|
) {
|
||||||
RichText(
|
RichText(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
style = RichTextStyle.Default,
|
style = RichTextStyle.Default.copy(stringStyle = stringStyle),
|
||||||
) {
|
) {
|
||||||
Markdown(text)
|
Markdown(text)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue