Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About
Building out a surface where navigation transitions can be overridden at navigation time based on the type of navigation event and the source/target screens.
Due to how shared element transitions work with
AnimatedContent
, we need some ability to completely replace the the transition spec before the target shared elements are loaded into the composition. Can look atPetDetailAnimatedNavigationOverride
for an example of this.AnimatedNavigationTransform
usageTransition Spec
AnimatedNavigationTransform.NavigationEvent
indicating the type ofnavigation event that is occurring (
GoTo
,Pop
,RootReset
).AnimatedContentTransitionScope
, from which you can get theinitialState
andtargetState
of the transition, as well as use the helper functions.ContentTransform
if you want to override the default transition for the givenNavigationEvent
and state, returnnull
otherwise.Transition Selection
AnimatedNavDecoration
will compare each of the availableAnimatedNavigationTransform
s and select the first one that is able to handle the currenttransition. If no
AnimatedNavigationTransform
is able to handle the transition, then thedefault transition provided by the
AnimatedNavDecorator.defaultTransform
will be used.Example
The example checks if the user is navigating to the
PetDetailScreen
from theHomeScreen
, with the information needed to tie together a shared element transition. If that is the case no transitions are used, otherwise it returns null to continue checking otherAnimatedNavigationTransform
s or fallback to theAnimatedNavDecorator.defaultTransform
.Demo
Notice how on the forward navigation the grid view is sliding out, on the pop
AndroidPredictiveBackNavDecorator
already removes the animation.before.mp4
after.mp4
Questions
AnimatedNavigationTransform
make sense as a general interceptor?animatedNavigationOverride
methodScreen
?CircuitInject
, or other navigation setups.Navigator
methodsAnimatedNavigationTransform
implementations into theCircuit
instance