https://kotlinlang.org logo
i

Isaac Udy

12/16/2019, 6:56 PM
I'd like to bump this to see if anyone's got any answers. I'm looking to change an animation based on inputs, but allow children composables to maintain their state (+state and +memo). I've found a very rough work-around to this using
Key
and lists, but it doesn't work very well unless you know all the animation functions that might be called upfront. What works:
Copy code
val myThings = listOf(...)
for(item in myThings) {
  Key(item.id) {
    animationOne(progress = ...) {
      animationTwo(progress = ...) {
        item.composable()
      }  
    }
  }
}
The problem with this is that I need to know animationOne and animationTwo upfront, rather than being able to choose arbitrary animations based on some item in myThings. The main place I would like to do this is in defining "Screen" composables that can be animated in/out from each other, with a custom enter/exit animation defined in each Screen, but changing the animations that wrap a screen that's already been rendered will reset the states/memos inside of the animation block (I assume because there's different group starts).