mars885 / gamedge

An Android application for browsing video games and checking the latest gaming news from around the world.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mars885 opened this issue · comments

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() {
  // ...
}