Example written in compose for managing multiple backstacks using navigation component and bottom navigation
- It always takes the user back to the first tab irrespective for the order they were opened.
- Separate the navigation graph for each tab
- When BottomNavigation moves through each tab, it saves the state of the previous tab and restores the state when the previous tab is selected again.
- If you press the selected tab once more, it moves to the root of the graph of the selected tab.
- Case 1
- Case 2
- Case 3
- Case 4
- Case 5
- User Action
- Click HomeTab -> Click CompanyTab -> Move to DetailScreen -> Move Company DetailScreen 2 -> Click NotificationTab -> Click CompanyTab -> Click CompanyTab
- Result
- HomeTab -> CompanyTab -> CompanyDetailScreen -> CompanyDetailScreen2 -> NotificationTab -> CompanyDetailScreen2 -> CompanyTab(Root)
- Preview
- User Action
- Case 6
- User Action
- Click HomeTab -> Click CompanyTab -> Move to DetailScreen -> Move Company DetailScreen 2 -> Click NotificationTab -> Click CompanyTab -> Perform BackPressed -> Perform BackPressed -> Perform BackPressed
- Result
- HomeTab -> CompanyTab -> CompanyDetailScreen -> CompanyDetailScreen2 -> NotificationTab -> CompanyDetailScreen2 -> CompanyDetailScreen -> CompanyTab(Root) -> HomeTab
- Preview
- User Action