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

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.