Navigating to a new screen in Compose
We will build a register screen prompt on our login page for registering first-time users of our application. This is a standard pattern because we need to save the user’s credentials so that the next time they log in to our application, we just log them in without registering again.
Getting ready
You should have completed the previous recipe, Implementing a bottom navigation bar using navigation destinations, before getting started with this one.
How to do it…
In this recipe, we will need to use our SampleLogin
project and add a new screen that users can navigate to if it is their first time using the application. This is a typical use case in many applications:
- Open your
SampleLogin
project, create a newsealed
class, and call itDestination
. To also ensure we maintain great packaging, add this class toutil
. Also, just like the bottom bar, we will have a route, but this time, we do not need any icons or titles...