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

[FR] Support Compose Animation #752

Open yschimke opened 1 year ago

yschimke commented 1 year ago

I guess a 3 part request. Feel free to close if out of scope, I'm basically getting some thoughts down.

1) Support Compose Animation with samples.

Presumably now working since some recent fixes like https://github.com/cashapp/paparazzi/pull/739

2) Allow snapshotting/gif synced to animation progress.

If animation state isn't externalised, it seems difficult to snapshot at exactly the right frame. But if we can using the same approach as Android Studio animation tooling, then we can capture the exact values.

3) Allow capturing a gif of a animation.

Similar to the interactive previews in Android Studio, for the various transitions supported in Android Studio, allow capturing a gif of the transition from start to end.

For 2+3 - we could use a similar approach to Android Studio, which searches the compose slot tables for known animation types and uses them to examine or control the animation.

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-tooling/src/androidMain/kotlin/androidx/compose/ui/tooling/animation/AnimationSearch.kt

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-tooling/src/androidMain/kotlin/androidx/compose/ui/tooling/animation/AnimatedVisibilityComposeAnimation.kt

Something like the following will capture composition data, allows traversing the tree to find the types like Animatable, Transition.

        val store = mutableSetOf<CompositionData>()

            store.add(currentComposer.compositionData)
            CompositionLocalProvider(
                LocalInspectionMode provides true,
                LocalInspectionTables provides store
            ) {
              // animation to preview
            }
leo-beliakov commented 1 month ago

@jrodbx Any updates on this?