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

Qualified night/dark assets not being picked up in @Preview snapshot tests #377

Open
drinkthestars opened this issue Apr 4, 2024 · 0 comments

Comments

@drinkthestars
Copy link

Given the following:

@Preview(name = "TestBox - Light")
@Composable
fun TestPreviewLight() {
    TestBox()
}

@Preview(name = "TestBox - Dark", uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
fun TestPreviewDark() {
    TestBox()
}

@Composable
fun TestBox(
    modifier: Modifier = Modifier
) {
    Box(
        modifier = modifier.size(100.dp)
    ) {
        Image(
            imageVector = ImageVector.vectorResource(id = R.drawable.test_drawable),
            contentDescription = "Testing background",
        )
    }
}

where the R.drawable.test_drawable is a vector that references night/day qualified colors or has a drawable-night equivalent, the recorded snapshots only show the light variant - somehow the dark/night qualified assets are not being picked up:

Preview:
Screenshot 2024-04-04 at 1 53 35 AM

Golden Snapshots:
Screenshot 2024-04-04 at 1 52 45 AM

Tried the following to try to force it, but didn't work either:

@Preview...
fun TestPreview() {
    val customConfiguration = Configuration(LocalConfiguration.current).apply {
        uiMode = Configuration.UI_MODE_NIGHT_YES
    }
    CompositionLocalProvider(LocalConfiguration provides customConfiguration) {
        TestBox()
    }
}

Is this a bug/limitation or is it a config issue? Thanks!

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