grahammendick / navigation

Scene-Based Navigation for React and React Native
https://grahammendick.github.io/navigation/
Apache License 2.0
571 stars 40 forks source link

Supported predictive back on Material Transitions #786

Closed grahammendick closed 3 months ago

grahammendick commented 3 months ago

Predictive back is buggy and this caused confusion when working on #781. Couldn’t work out what was breaking - was it shared elements? Was it when only one transition was specified? Different scenarios gave different breakages. So put in VoidTransition to just turn off predictive back when not using Animators.

But after revisiting it was actually VoidTransition that broke the predictive back with Material Transitions. For example, cancel the gesture back and then a second gesture back would show a blank screen. Removing VoidTransition fixed this. As long as all four Transitions are specified (enter, exit, reenter, return) then gesture back works for Material Transitions.

The cmd + del on Android emulator doesn’t go back with predictive back enabled and Material Transitions. With predictive back disabled and/or with Animators it works. Not a blocker because only an emulator issue.

Also fixed enableOnBackInvokedCallback set to true on API < 34 where swipe back stopped the previous scene from being interacted with. This is yet another Android bug. For example, navigate from A → B → C and gesture back. Android calls onBackStackChangeStarted twice, once passing in fragment B and again passing in fragment C. On API 33 fragment C isRemoving (correct) but on API 34 fragment B isRemoving (incorrect). Used the keys length to work out the previous crumb instead of using the removing fragment.