nglauber / JetpackComposePlayground

41 stars 5 forks source link

BackStack not working with Bottom Navigation Bar. #1

Open parveensharmayml opened 2 years ago

parveensharmayml commented 2 years ago

Hi, as per with the current implementation Bottom Tabs are not retaining their states. Can you provide some example where Bottom Tabs can retain their states in following scenarios:

  1. On BackPress
  2. On Tab Click
  3. Nested Navigation The third point - Can you explain how to navigate from Graph1Screen2 to Graph2Screen2 (Nested Navigation) so that when user back press it should navigate back to previous nested screen of previous graph (Graph1Screen2) whether user pressed back button or switching tab, it should retain old state.
nglauber commented 2 years ago

Hey @parveensharmayml, thanks for reporting this issue. I recreated this sample and pushed the code. Could you take a look if it's working as expected?

parveensharmayml commented 2 years ago

@nglauber Thankyou for fixing this. But just a question for you again. You are navigating to Tab2Details from Tab1Details like this.

navigate(navController, TabItem.Tab2.route)
                        navController.navigate(TAB_2_DETAILS)

But my third point was to navigate to TAB_2_DETAILS directly rather than switching tab. Then from TAB_2_DETAILS if user press back button or switch tab TAB_1_DETAILS should open.

Also Next Point: You are navigating back (on back pressed) to Initial Tab from TAB_2_MAIN like navigate(navController, TabItem.Tab1.route)

Let's say there are multiple tabs and we want to navigate back to last opened tab. Can you describe it in more generic way ? Reference: navigate(navController, dynamicRoute)

Again, Thanks for this wonderful example.