Navigation in Jetpack Compose - Fragments/ViewModels

1.8k Views Asked by At

So I'm checking this official Compose tutorial https://developer.android.com/courses/pathways/compose

There is Jetpack Compose Navigation

https://developer.android.com/codelabs/jetpack-compose-navigation

So basically in that sample there is just one activity, no fragments and composables (implements 3 screens) are used for navigation graph instead of fragments

This sample is also really bad because it doesn't have ViewModels at all...

So basically how would a real app would look right now?

A single Activity with a single ViewModel and a lot of screens made in composables which use the same ViewModel (which of course is really bad)? Or I guess we should add a separate ViewModel inside of each start composable function of a specific screen instead of Activity (which could have only one single ViewModel - one lifecycle)

enter image description here

So basically we don't need fragments any more nowadays?

0

There are 0 best solutions below