Calvin-LL / AutoLinkText

A simple library that makes links, emails, and phone numbers clickable in text in Jetpack Compose and Kotlin Compose Multiplatform.
Apache License 2.0
57 stars 2 forks source link

[Feature Request] Make default text color configurable #3

Open matsumo0922 opened 1 week ago

matsumo0922 commented 1 week ago

Now AutoLinkText has no argument to set the text color, so if you want to set the default text color, you must use TextStyle to do so.

However, this Style takes precedence over TextRule.style, so the color of links, etc. will be consistent. Could you prevent this and still set the default text color?

↓ Current workaround (not smart :( )

AutoLinkText(
    text = description,
    style = MaterialTheme.typography.bodyMedium.copy(color = MaterialTheme.colorScheme.onSurfaceVariant),
    textRules = TextRuleDefaults.defaultList().map {
        it.copy(
            style = SpanStyle(
                color = MaterialTheme.colorScheme.primary,
                textDecoration = TextDecoration.Underline,
            )
        )
    },
)
Calvin-LL commented 4 days ago

I'll take a look at this next week. Meanwhile, if anyone else want this, feel free to open a PR.