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

@@ -17,10 +17,10 @@
package io.element.android.services.apperror.impl
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import io.element.android.libraries.designsystem.preview.ElementPreviews
import io.element.android.libraries.designsystem.components.dialogs.ErrorDialog
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
import io.element.android.services.apperror.api.AppErrorState
import io.element.android.services.apperror.api.aAppErrorState
@@ -50,11 +50,13 @@ fun AppErrorViewContent(
)
}
@Preview
@ElementPreviews
@Composable
internal fun AppErrorViewLightPreview() = ElementPreviewLight { ContentToPreview() }
internal fun AppErrorViewLightPreview() {
ElementPreview { ContentToPreview() }
}
@Preview
@ElementPreviews
@Composable
internal fun AppErrorViewDarkPreview() = ElementPreviewDark { ContentToPreview() }