cashapp / paparazzi

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

`offsetMillis` in Compose #627

Open JavierSegoviaCordoba opened 1 year ago

JavierSegoviaCordoba commented 1 year ago

A function that includes offsetMillis is missing for Compose.

It should be great if it could be added, and instead of using a Long it uses Duration.

snapshot functions can be mixed with the View one. Maybe the Gradle plugin can take an enum so:

enum class UiSystem {
    Compose,
    View,
    Both,
}

This would allow to Paparazzi Gradle plugin to only apply one library if the consumer is not using both systems, and that can enable splitting the Paparazzi snapshot functions into different modules, per system. or both.

alashow commented 1 year ago

For some reason I expected this to work but it doesn't:

fun Paparazzi.snapshot(
    name: String? = null,
    offsetMillis: Long = 0L,
    composable: @Composable () -> Unit,
) {
    val hostView = ComposeView(context)
    hostView.setContent(composable)
    snapshot(hostView, name, offsetMillis)
}
ArcaNO93 commented 3 months ago

@jrodbx code snippet provided by @alashow does not work for me either can you please confirm whether the offsetMillis param works for compose?

Burtan commented 2 months ago

I cannot get animations to work either in compose (showing snackbars). It works when using @Preview in interactive mode.

leo-beliakov commented 2 months ago

@jrodbx Any updates on this?