ncapdevi / FragNav

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

What is the best practice show full screen fragment without independent from stack #236

Open skyberk opened 3 years ago

skyberk commented 3 years ago

Hi,

Firstly thank you for this awesome library,

I am using this library with bottom bar(bottom bar in my activity) but sometimes i need to push/show fragment without bottom bar. In this case user cannot switch selected tab. I am setting visibility gone to bottombar when pushing fragment whatever stack. When user navigate to back i am setting visibility visible to bottombar. But i am not sure about this way is correct.

Should i create match parent second FrameLayout for full screen fragments in my activity. But i think FragNav and supportFragmentManager manual usage can be conflict same time.

Also i don't want to start new activity for this case because multiple activities always can be dangerous as you know.

Sh0rxy commented 3 years ago

I had the same problem a while ago and solved it via using two different FragNavControllers. Since you have to declare a view as attaching point for your fragments in the initalisation process of your FragNavController, which you cannot change afterwards, you have to use two different Controllers to fulfill your needs. I created one FragNavController which is being instantiated inside the Activity and handles Overlays that fill out the whole screen. The second FragNavController gets created inside of the "MainFragment" that handles all the "tabbing" work of your application. That means you have to move all your code that handles the tabs and the bottom bar from your activity to this newly created Fragment.

Alternatively it is also possible to use a DialogFragment. I did not look into workings of the DialogFragment yet, that means I am only making assumptions in the following. I guess this will push itself over every view and viewgroup regardless of declared position of the view. But from your explanations

I assumed that you did not need a Dialog but a Fragment that covers the whole screen, so the second solution might not be what you are looking for. Also your solution now is working, which, in my opinion, means, that it is a viable solution. On the other hand, my first proposal would result in a more organized and encapsulated code, what will help future you and others working with that code.