Decompose: stack animation break text color

MyApplication.zip

  1. click testA button, you could see test button enable/disable correctly.
  2. switch to another tab and switch back
  3. click testA button again, text color of test button stick with same color (but button color change state correctly).
  4. remove stack animation, text color change correctly.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

The cause issue in Compose has just been marked as fixed. I think the fix should go in the next Compose release (22nd April).

Maybe it worth releasing v2.0.0 together with the API changes from #327?

  1. Unfortunately, I don’t know. The issue is also reproducible on Jetpack Compose 1.3.1.
  2. The official navigation may work fine because it has a very limited support of animations.
  3. This is tricky and not possible without breaking the API. movableContentOf appears to be pretty unstable, but it is used by Stack Animations in order to allow having different animations for different children/directions/etc. The should be possible to avoid movableContentOf for the simple variant of stackAnimation function without selector argument. Though some minor changes to the API will be still required. For the variant with selector this is even more complicated.

For now I’m willing to wait for the fix and monitor how this will be doing in the future. The sibling issue #326 with scrolling in JetBrains Compose is already fixed (and perhaps released). Breaking the API is pretty undesirable, as movableContentOf allowed me to make the API simpler and concise.

It appears that accompanist uses androidx.compose.animation, which has a fixed set of possible transitions. For instance, here is EnterTransition. It has fade, scale, slide and expand, and perhaps combinations. But it doesn’t look possible to define custom transitions. In this case it’s obvious that movableContentOf is not needed.

Stack Animation API in Decompose allows custom transitions. But anyway, I will think if there any ways to avoid movableContentOf.

The fix on the Decompose side will be released in the next major update, as described in https://github.com/arkivanov/Decompose/issues/330#issuecomment-1454792564.

I will check accompanist animations, maybe we could derive something from there. Thanks for sharing.

Thanks for providing the workaround!