question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Idea] [Navigation Animation] Animations between destinations with and without Scaffold

See original GitHub issue

In general, it is advised to only use a single (Animated)NavHost. However, as of now, nice transitions between screens with Scaffold and screens without Scaffold are not possible with a single NavHost. Consider this example:

https://user-images.githubusercontent.com/6752601/133760459-819151c3-bd23-4785-9124-699be273dbbc.mp4

I need to wrap the NavHost for the two bottom bar destinations in a common Scaffold to properly animate the BottomBar. With this configuration, the transition to the image screen above the bottom bar (in z-direction) is only possible by adding a second NavHost, which contains the image screen and the main NavHost.

I see two options here:

  • Make it possible to lay out some NavHost destinations above the top and bottom bar of the Scaffold. I don’t think this is currently possible in Compose, so this might be very difficult to implement.
  • Add a NavGraphBuilder function which adds wrapping composables to certain destinations. In this case, both bottom bar destinations would be wrapped in such a function, which would add the Scaffold to these screens.

Probably, there are more options. Personally, I would favor the second option. I know, this is not really in scope of Accompanist, but since Accompanist Navigation currently contains the next-gen NavHost implementation, I wanted to start here.

What are your opinions on this?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:6

github_iconTop GitHub Comments

2reactions
ianhanniballakecommented, Nov 16, 2021

FWIW, we’ll be continuing to look at this as part of the explorations into shared elements (part of the Jetpack Compose Roadmap and their integration into Navigation, which would be the mechanism you’d want to use share an element across multiple (but perhaps not all) screens.

That kind of solution would still only use a single NavHost though.

0reactions
fschuetz04commented, Oct 28, 2021

By the way, a bare-bones implementation of the second approach: https://github.com/fschuetz04/compose-navigation-test.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Animate transitions between destinations - Android Developers
Animate transitions between destinations with Jetpack's Navigation component.
Read more >
Compose Destinations: type-safe, simple navigation
This makes it easy to animate between destinations and use bottom sheet-styled destinations. Read more in this wiki. Truly safe string navigation arguments....
Read more >
Hero animations - Flutter documentation
The simplest example of a radial hero animation. The destination route has no Scaffold, Card, Column, or Text. This basic example, provided for...
Read more >
Everything you need to know about Flutter page route transition
We know how easy it is to navigate from one route to another in ... We can create our own custom page route...
Read more >
Level up Flutter page transition: choreographing animations ...
Hero computes the size of source hero widget and size of destination hero widget. · Hero creates RectTween to animate the Widget from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found