cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.25k stars 213 forks source link

Gif support for Compose #496

Open JavierSegoviaCordoba opened 2 years ago

JavierSegoviaCordoba commented 2 years ago

Paparazzi hasn't Gif support for Compose, it should be great if it was added.

Is it possible, as a workaround, to wrap the composable with AndroidView?

redwarp commented 1 year ago

In the meantime, this totally works:

val view = ComposeView(paparazziRule.context)
view.setContent {
    PaparazziTestTheme(darkTheme = true) {
        Page()
    }
}
paparazziRule.gif(view, "test", 0L, 500L, 30)
hlandim commented 1 year ago

In the meantime, this totally works:

val view = ComposeView(paparazziRule.context)
view.setContent {
    PaparazziTestTheme(darkTheme = true) {
        Page()
    }
}
paparazziRule.gif(view, "test", 0L, 500L, 30)

Well, it worked but, It generated a .mov file instead of a .gif in the videos folder. Also, it generated a bunch of images in the screenshot folder, which I would assume that these are the .gif frames. Is that the expected result?? image

lib version used: 1.3.1

redwarp commented 1 year ago

Yep, if you look at the source code, that is expected: https://github.com/cashapp/paparazzi/blob/master/paparazzi/src/main/java/app/cash/paparazzi/HtmlReportWriter.kt. The way it works is that every frame is generated, and then assembled in a video.

Arguably, it could be cleaned.

As of now, the snapshot verifier does not verify videos, just fixed images: https://github.com/cashapp/paparazzi/blob/master/paparazzi/src/main/java/app/cash/paparazzi/SnapshotVerifier.kt

TWiStErRob commented 1 year ago

Note that there are some gif related PRs open, some might be related: https://github.com/cashapp/paparazzi/pulls?q=is%3Apr+is%3Aopen+gif