jeziellago / compose-markdown

Markdown Text for Android Jetpack Compose 📋.
MIT License
507 stars 40 forks source link

Color does not change dinamically #75

Open adrifernandev opened 6 months ago

adrifernandev commented 6 months ago

Hi there! When you use color that has to change for some reason it does not change so it stays with the first color that the composable receives.

MarkdownText(
                markdown = stringResource(id = text),
                style = SplitTheme.typography.body.l,
                fontResource = R.font.poppins_regular,
                linkColor = SplitTheme.colors.neutral.textLinkDefault,
                onLinkClicked = { link ->
                    uriHandler.openUri(link)
                },
                color = if (isError) {
                    SplitTheme.colors.error.textDefault
                } else {
                    SplitTheme.colors.neutral.textBody
                }
            )

I'm using version 0.3.7

jeziellago commented 5 months ago

Hi, @adrifernandev Thanks for reporting. Please update to the latest version and check if the issue still happens.

fngbala-luna commented 2 months ago

Hi 👋 I still have the issue on the 0.4.1 version : When the color changes dynamically, the text color changes but not the link color

@Composable
fun MyMarkdownText(
    style: TextStyle,
    text: String,
    modifier: Modifier = Modifier,
    color: Color,
    onLinkClicked: (String)->Unit
) {
    MarkdownText(
        modifier = modifier,
        markdown = text,
        linkColor = color,
        style = style.copy(color = color),
        fontResource = R.font.montserrat_regular,
        onLinkClicked = onLinkClicked
    )
 }

 //  Usage  :  
 MyMarkdownText(
    text = label,
    style = MaterialTheme.typography.bodyMedium,
    color = if(isOnError) {
         textError
     } else {
          textColor
     },
    onLinkClicked = onClickOnLink
)

Initial state :

After the color change