{"id":27635120,"url":"https://github.com/vipulasri/multiple-backstack-navigation","last_synced_at":"2025-04-23T19:44:36.639Z","repository":{"id":54658676,"uuid":"279639184","full_name":"vipulasri/Multiple-Backstack-Navigation","owner":"vipulasri","description":"Handling multiple backstack histories for each tab in Bottom Navigation using Navigation Component. ","archived":false,"fork":false,"pushed_at":"2021-02-05T12:00:41.000Z","size":409,"stargazers_count":63,"open_issues_count":7,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-02T00:56:18.334Z","etag":null,"topics":["android","jetpack","jetpack-navigation","navigation-architecture-component","navigation-component"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vipulasri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-14T16:35:17.000Z","updated_at":"2023-07-13T11:35:00.000Z","dependencies_parsed_at":"2022-08-13T23:01:14.547Z","dependency_job_id":null,"html_url":"https://github.com/vipulasri/Multiple-Backstack-Navigation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vipulasri%2FMultiple-Backstack-Navigation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vipulasri%2FMultiple-Backstack-Navigation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vipulasri%2FMultiple-Backstack-Navigation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vipulasri%2FMultiple-Backstack-Navigation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vipulasri","download_url":"https://codeload.github.com/vipulasri/Multiple-Backstack-Navigation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250501710,"owners_count":21441065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","jetpack","jetpack-navigation","navigation-architecture-component","navigation-component"],"created_at":"2025-04-23T19:44:36.029Z","updated_at":"2025-04-23T19:44:36.618Z","avatar_url":"https://github.com/vipulasri.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Multiple Backstack Navigation (Navigation Component)\n\nAs of now [Navigation Component](https://developer.android.com/guide/navigation/navigation-getting-started) doesn't support multiple backstack management out of the box most commonly used in Bottom Navigation.  \n\nGoogle already has an [Advanced Navigation Sample](https://github.com/android/architecture-components-samples/tree/master/NavigationAdvancedSample) which showcases handling of multiple backstacks. \n\n**Cons:** \n\n1. It always takes the user back to the first tab irrespective for the order they were opened. \n2. Subjective approach, it attaches and detaches the navigation graph each time user navigates through bottom navigation view.\n3. It's difficult to add custom backpress action (ex: saving the data on certain screen before switching tabs) through their implementation.\n\n----\n\nThere are other resources as well to solve these issues, most commonly using ViewPager: [Instagram style navigation using Navigation Component](https://android.jlelse.eu/instagram-style-navigation-using-navigation-component-854037cf1389)\n\n**Major Issue:** App crashes on configuration change i.e \"[no nav controller attached on configuration change](https://github.com/ebi-igweze/ViewPagerNavigation/issues/1)\"\n\n----\n\n**This repository/sample** solves all the issues mentioned above. \n\n1. It takes consideration of user actions and navigates use back in the same order. \n\n    Example: \n\n    `User action: Tab 1 -\u003e Tab 2 -\u003e Tab 3 -\u003e Tab 2`\n\n    `Result: Tab 1 -\u003e Tab 3 -\u003e Tab 2`\n    \n2. 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()`. \nSo, I achieved that by setting their max lifecycle using `SetMaxLifecycle` to have `onPause()` and `onResume()` callbacks.\n\n3. I can set custom backpress action before switching tab's navigation. \n4. ***Brownie Point:*** It supports configuration change and restores the from the same state the navigation was on. \n\n\nPreview:\n\n![Showcase](art/showcase.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvipulasri%2Fmultiple-backstack-navigation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvipulasri%2Fmultiple-backstack-navigation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvipulasri%2Fmultiple-backstack-navigation/lists"}