Auto generate dark mode previews and screenshots (#776)

With this change, composable previews and screenshots should be created with just:
```
@ElementPreviews
@Composable
fun MyViewPreview() {
    ElementPreview { 
        MyView()
    }
}
```

- Adds `@ElementPreviews` which is a shorthand for:
```
@Preview(name = "D")
@Preview(name = "N", uiMode = Configuration.UI_MODE_NIGHT_YES)
```
Should be used in connection with the now public `fun ElementPreview()` composable.

- Adds ElementPreviews to previewAnnotations in dangerfile
- Screenshots of night mode previews are now rendered with night mode
- Replaces `ElementPreviewLight` and `ElementThemedPreview` with `ElementPreview`
- Deprecates `ElementPreviewDark` which should be removed.
- Remaining usages of `ElementPreviewDark` are now ignored during screenshot tests
This commit is contained in:
Marco Romano 2023-07-05 13:58:24 +02:00 committed by GitHub
parent d68526ee18
commit 79b529193c
1247 changed files with 2264 additions and 1939 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.ElementPreviews'
]
const filesWithPreviews = editedFiles.filter(file => file.endsWith(".kt")).filter(file => {