fix animateContentSize NavHost Modifier #315
Merged
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.
Changed
NavHost
layout implementation so thatBoxWithConstraints
layout that wraps theNavHostContent
will be composed only when there's aBackStackEntry
to display.There is an issue when the
NavHost
is inside aModalBottomSheet
, and theNavHost
is wrapped byanimateContentSize()
Modifier. It interferes with showing animation of the bottom sheet, where it hangs for an additional ~600ms at the bottom of the screen. It appears that not composing the layout (BoxWithConstraints
) when there's noBackStackEntry
solves the issue.Issue link: #313
Changes:
if
statement wrappingBoxWithConstraints
so that it'll compose only whencurrentSceneEntry
orcurrentFloatingEntry
is not null.We could avoid the
if
if not for the floatingBackStackEntry
which is also wrapped by the sameBoxWithConstraints
layout. If you have any idea how we could avoid it in some other way, feel free to update the PR with new changes. Or instead of nesting the rest of the logic inside theif
we could invert it and do areturn
so the rest of the function won't run.