Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources-composable should have a ColorDesc.localized() function #752

Open
dalewking opened this issue Aug 2, 2024 · 1 comment
Open

Comments

@dalewking
Copy link

StringDesc has a localized function, but for some reason ColorDesc does not.

@dalewking
Copy link
Author

dalewking commented Aug 2, 2024

This is what I implemented in our code:

@Composable
fun ColorDesc.localized(): Color = when (this) {
    is ColorDescResource -> colorResource(resource)
    is ColorDescSingle -> Color(color.argb)
    is ColorDescThemed -> when {
        isSystemInDarkTheme() -> Color(darkColor.argb)
        else -> Color(lightColor.argb)
    }
    else -> throw NotImplementedError()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant