Giter Club home page Giter Club logo

multiple-backstack-navigation's Introduction

Multiple Backstack Navigation (Navigation Component)

As of now Navigation Component doesn't support multiple backstack management out of the box most commonly used in Bottom Navigation.

Google already has an Advanced Navigation Sample which showcases handling of multiple backstacks.

Cons:

  1. It always takes the user back to the first tab irrespective for the order they were opened.
  2. Subjective approach, it attaches and detaches the navigation graph each time user navigates through bottom navigation view.
  3. It's difficult to add custom backpress action (ex: saving the data on certain screen before switching tabs) through their implementation.

There are other resources as well to solve these issues, most commonly using ViewPager: Instagram style navigation using Navigation Component

Major Issue: App crashes on configuration change i.e "no nav controller attached on configuration change"


This repository/sample solves all the issues mentioned above.

  1. It takes consideration of user actions and navigates use back in the same order.

    Example:

    User action: Tab 1 -> Tab 2 -> Tab 3 -> Tab 2

    Result: Tab 1 -> Tab 3 -> Tab 2

  2. In my approach, I am following show/hide of navigation graph, once they are created. While using Fragment Manager's show/hide, it doesn't call Fragment's onPause() and onResume(). So, I achieved that by setting their max lifecycle using SetMaxLifecycle to have onPause() and onResume() callbacks.

  3. I can set custom backpress action before switching tab's navigation.

  4. Brownie Point: It supports configuration change and restores the from the same state the navigation was on.

Preview:

Showcase

multiple-backstack-navigation's People

Contributors

vipulasri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

multiple-backstack-navigation's Issues

Asking for help to add navigation drawer

Hey Vipul Thanks for the great repo. I am looking to add navigation drawer to the same. But not sure how to achieve the same. Need your help to add the navigation drawer along with bottom navigation view

How to add new fragment in the root of mobile_navigation

Hi,
Your repo so greate. But, I'm looking for the solution to add a fragment which have same level with form, home, list.
That's mean the application have the main screen is the same with the current repo. I need more fragment like that:

<navigation
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/app_navigation"
    app:startDestination="@id/home">

    <include app:graph="@navigation/home" />

    <include app:graph="@navigation/list" />

    <include app:graph="@navigation/form" />

    <action android:id="@+id/action_open_detail"
        app:destination="@id/nav_detail"/>

    <fragment android:id="@+id/nav_detail"
        android:name="com.example.android.navigationadvancedsample.detail.Detail"
        android:label="Detail"
        tools:layout="@layout/fragment_detail"/>

</navigation>

I want to open the detail screen in the tab screen and I will be hide the bottomnav when open the detail screen from any tab by handle destination changed.
Howerver, I navigation by findNavController().navigate(R.id.action_open_detail). But I have got error: navigation destination com.example.android.navigationadvancedsample:id/action_open_detail is unknown to this NavController

Have any suggest to open detail nav?

Thanks for your time.

Home fragment back stack

Hello sir Im sorry for opening an issue please let me know if its a default behaviour or if there is a solution to solve it. Also I wanted to thanks your efforts for developing such a great approach to solve an important problem.
The problem is the first time that you open the application if you navigate to to this fragment
Screen Shot 2021-06-30 at 12 38 06 PM

and then if you press the back button your application will be closed and and you can not return to the home fragment.

Unable to change default navigation

Tried to change the default navigation from Home -> Dashboard, but not working.

Changed in mobile_navigation.xml, BottomNavManager... But always opening the home navigation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.