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

Create a custom @Preview annotation as a shortcut for both light & dark themes #201

Open
mars885 opened this issue Aug 1, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@mars885
Copy link
Owner

mars885 commented Aug 1, 2022

Apparently, starting from Compose 1.2, it's possible to create a single annotation for previewing multiple configurations of a particular composable instead of duplicating @Preview multiple times everywhere.

However, as of Jetpack Compose version 1.2 and Android Studio Chipmunk, preview just don't work. Therefore, as soon as previews get fixed, create a single preview annotation and use it for previewing composables. Something like this:

@Preview
@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES)
annotation class GamedgePreview

Then, use it like so:

@GamedgePreview
@Composable
private fun GameInfoLoadingStatePreview() {
  // ...
}
@mars885 mars885 self-assigned this Aug 1, 2022
@mars885 mars885 added the enhancement New feature or request label Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant