I'm studying Compose, ok it's wonderful but i have...
# compose
a
I'm studying Compose, ok it's wonderful but i have some doubts how i can use it in app production. App with 40-60 fragments Ok i tried Compose Navigation so my questions are: 1. can i use a screen compose for every hypothetical fragment? there are a lot of screen. 2. can i use fragments with compose UI and i use normal navigation component? 3. other ways
r
You can use Compose everywhere you already have Views, for instance inside existing fragments
a
so can i follow previous architecture ? : Activity - > (navHost Navigation) -> Fragments (every fragment has layout but with Commpose
i
We talk about interop in the docs as well: https://developer.android.com/jetpack/compose/navigation#interoperability - you'd continue to use Fragments (that just replace their
View
with a
ComposeView
) until all your fragments are converted, then swap over everything to Navigation Compose and remove all of the wrapper fragments
a
Ok i understand but i'd like to know best practise so question is : in a App with 40-50-60 fragments (if we think old approach) can i use Compose and replace all hypothetical fragments ? Could app have performance problems?
I'm starting a big project and I'm afraid if I use aan architecture or another... i can wrong
i
There's no need to use fragments in a pure Compose app; hundreds of screens is just fine in a Navigation Compose (i.e., no fragment) based app.
Once you get to that point (which obviously may take a while if you're going one fragment at a time 😅 ), I'd suggest reading this blog post, which has some good tips of structuring larger graphs into separate pieces: https://medium.com/google-developer-experts/navigating-in-jetpack-compose-78c78d365c6a
a
I have other questions such as how can use external UI (customview) library (XML layout) but thanks for now.
a
Wonderful thanks
a
I think the proper refactor way from XML to Compose for "Activity/Fragment mental" (like me) is to continue using Fragments & Navigation component with Compose instead of pure compose especially there are no advantages to using pure compose if you don't planning to work with KMP
1