Optional day night preview annotation (#793)

Adds the `@DayNightPreviews` annotation that when used on a composable will:
- Display both a day mode and night mode preview in Android Studio.
- Produce both a day and night screenshot during screenshot testing.

The usage of this new annotation is optional, all the current previews continue to work without breakages.
New code can use, when appropriate, the new `@DayNightPreviews` annotation and replace the pattern using three `LightPreview/DarkPreview/ContentToPreview` functions with:

```
@DayNightPreviews
@Composable
fun MyScreenPreview(@PreviewParameter(MyStateProvider::class) state: MyState) {
    ElementPreview {
        MyScreen(
            state = state,
        )
    }
}
```
This commit is contained in:
Marco Romano 2023-07-06 12:35:54 +02:00 committed by GitHub
parent 5cfaae24b8
commit 3449ea486a
8 changed files with 81 additions and 14 deletions

View file

@ -132,7 +132,8 @@ if (allowList.includes(user)) {
const previewAnnotations = [
'androidx.compose.ui.tooling.preview.Preview',
'io.element.android.libraries.designsystem.preview.LargeHeightPreview'
'io.element.android.libraries.designsystem.preview.LargeHeightPreview',
'io.element.android.libraries.designsystem.preview.DayNightPreviews'
]
const filesWithPreviews = editedFiles.filter(file => file.endsWith(".kt")).filter(file => {