$30 off During Our Annual Pro Sale. View Details »

Navigation in Jetpack Compose

Navigation in Jetpack Compose

Learn about navigation in Jetpack Compose using the Jetpack navigation library, and best practices when implementing navigation on your app.

Happy Composing! 🥳

Beatrice Kinya

June 16, 2023
Tweet

More Decks by Beatrice Kinya

Other Decks in Programming

Transcript

  1. Beatrice Kinya
    GDE for Android
    Android Engineer @ Kyosk Digital
    Android Author @ Kodeco

    View Slide

  2. Navigation
    Jetpack Compose

    View Slide

  3. Navigation Components
    - NavHost: A container where destinations are swapped in and out as a user
    navigates through your app.
    - NavController: Manages app navigation within a NavHost
    - Stateful
    - Keeps track of the back stack composables
    - Navigation destination: Composable screens.

    View Slide

  4. Code

    View Slide

  5. Co-locating Navigation Calls

    View Slide

  6. Passing Arguments between Destinations
    - You add argument placeholders to your route.
    - By default, all arguments are parsed as Strings.
    - You can create a NamedNavArgument using navArgument() method and specify
    the type.
    arguments = listOf(navArgument("itemId") { type = NavType.IntType })
    - You retrieve the argument from NavBackStackEntry available in the lamda of
    the composable() function.

    View Slide

  7. Bottom Navigation

    View Slide

  8. Questions

    View Slide