ncapdevi / FragNav

An Android library for managing multiple stacks of fragments
1.5k stars 220 forks source link

Navigating to a fragment not in bottom bar #40

Closed Grace0320 closed 7 years ago

Grace0320 commented 7 years ago

How would I go about navigating to a fragment that's not in my bottom bar menu? For example, my bottom bar has 5 options, but I also have a settings button I display at the top of the page. Currently, on clicking that button I push the settings fragment. Say I'm on Fragment1, and I click settings. I get taken to the settings fragment. I then use the bottom bar to go to Fragment2. If I now hit the tab on the bottom bad for fragment1, I see the settings page again, instead of fragment1. How do I pop the settings fragment when I leave it to navigate to another bottom bar tab?

ncapdevi commented 7 years ago

I think what you want to do is treat the settings menu as it's own tab, correct? In that case, we'd need to update the number of possible indexes (which isn't necessarily a bad idea. The other way to do this would be to handle it manually. I.e., before you switch tabs, you check if the current fragment is the settings fragment, and if it is, pop it. There's a getCurrentFragment() function available for this.