Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the bottom navigation #12

Closed
aidewoode opened this issue Jun 2, 2023 · 2 comments
Closed

Optimize the bottom navigation #12

aidewoode opened this issue Jun 2, 2023 · 2 comments

Comments

@aidewoode
Copy link
Member

Right now I just use ViewFlipper to switch the view on bottom navigation based on this issue hotwired/turbo-android#189. But it has some problems, for example it will render all view at once including home page, and library page when after lunched the app. And also ViewFlipper seems isn't the proper way to handle bottom navigation. So I need to find a better way to switch view for bottom navigation.

aidewoode added a commit that referenced this issue Jun 2, 2023
Fix #12, use Fragment transaction to handle bottom navigation
@MichalSznajder
Copy link

How did this solution (so delayed loading and swapping navHostFragments) worked comparing to using ViewFlipper ?

@aidewoode
Copy link
Member Author

@MichalSznajder First of all, ViewFilpper will eagerly load all child views, which means if you have multiple views based on TurboNavHostFragment, you will get multiple web page requests at once when using ViewFilpper to switch views. That's unnecessary. And second, I think using ViewFilpper for bottom navigation isn't a standard way before navigation graphs. And I also try to use nested navigation graphs to handle bottom navigation, but it didn't work with TurboNavHostFragment, that's because we need to handle currentNavHostFragmentId for TurboActivityDelegate manually. And I didn't find a way to handle this with nested navigation graphs.

Anyway, using supportFragmentManager is the best approach I found to deal with bottom navigation with turbo-android right now. And if you find a better solution for this problem, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants