Compose Navigation
Github repo: doctor-blue/compose-navigation
Cannot retrieve contributors at this time
Compose Navigation
This library will make it easier to pass arguments between screens in Jetpack Compose
Setup
How to use?
Step 1: Create your screen class and extend it with ComposeScreen class
Example: I have 3 screens (MainScreen, Screen1, Screen2). As you can see the _route variable is my screen name
Step 2: Create a class and implement it with Argument interface. Variables in this class is your argument you wanna pass to other screen.
Example: I want to pass a number from MainScreen to Screen2. More variables means more arguments
Step 3: Setup your navigation
Same as using navigation component, but at the composable function you can give ComposeScreen and Argument object, let me help you with the rest.
Support get argument from Bundle or SavedStateHandle. If Bundle or SavedStateHandle object doen't contains key argument will be default of Argument object
Step 4: Navigate to other screen
Example 1: just open Screen1
Example 2: pass random number to Screen2
Note
You can get Argument object from arguments (Instance of Bundle) like example above.
Or get data from SavedStateHandle like this
Want more an example?
See Note app
Donate
Last updated