google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.43k stars 598 forks source link

[Navigation Animation] Change zIndex to match navigator back stack #1455

Closed jbw0033 closed 1 year ago

jbw0033 commented 1 year ago

The zIndex is currently based on the index of the entry from the list of visible entries available in the navigator. The visible entries get recreated each time the back stack changes and this means the index of the entries changes as well. When doing a pop, the zIndex of the ContentTransform is 0, when there is an additional pop, the zIndex of the new ContentTransform is also 0. Since both of them have the same value, the new ContentTransform is on top and that causes the pop enter transition to be on top.

If we provide the value of the back stack as the zIndex instead, each ContentTransform will increase in value as the stack gets larger, and when popping, the zIndex of outgoing entries will never be the same as the zIndex of incoming entries.

Fixes #1411