Full Guide to Nested Navigation Graphs in Jetpack Compose

Full Guide to Nested Navigation Graphs in Jetpack Compose

Philipp Lackner

1 год назад

57,988 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Richard CG
Richard CG - 19.10.2023 03:53

The solution I was looking for, thanks a lot, Philipp! I love your videos

Ответить
Lutfi-haslab
Lutfi-haslab - 17.10.2023 05:21

Sorry, i have followed you for a while since i learn jetpack compose. Maybe you can give the view result everytime you make the tutorial hehe

Ответить
RyoKuMan
RyoKuMan - 12.10.2023 07:29

I don't know why, all of your videos which is adding some new implements like lifecycle or something
like this video and calculator

I can't build anything really
it always has an error for duplicated implements
I think there is a prob with your impllements,
can you check them?

Ответить
Franky Junior
Franky Junior - 10.10.2023 15:15

Please make video nested nav with compose destinations libs. Thank you

Ответить
jayesh kumar
jayesh kumar - 04.10.2023 14:17

I was using 2.5.3 version, now when I want to update to 2.7.2 am facing some issues, is there any major changes need to be done?

Ответить
Dolakrishnan Seshachalam
Dolakrishnan Seshachalam - 14.09.2023 09:26

Hi Philipp, Once User Successfully Logged in, For Calendar Route Can we use One More NavHost with NavController()

Ответить
Andrew Dunbar
Andrew Dunbar - 02.09.2023 09:06

Only A few do it right.

Ответить
Vinaykumar Patel
Vinaykumar Patel - 28.08.2023 17:13

I wonder is there any changes on how we use Hilt on Jetpack?

Ответить
Volodymyr M
Volodymyr M - 16.08.2023 12:01

How can I add ViewModelFactory?
backStackEntry.sharedViewModel<MyViewModel>( navController = navController, factory = MyViewModelFactory())
Or create one under composable and set a link to each one

Ответить
Adam Fatyga
Adam Fatyga - 11.08.2023 09:46

Doesn't work, graph need

Ответить
jp romero
jp romero - 11.08.2023 03:17

We need another video for nested navigation

Ответить
Morteza Taghdisi
Morteza Taghdisi - 09.08.2023 20:24

Thanks Philip for another wonderful video. I have a question, what if I want to share a Koin view model instead of normal view model. How the sharedViewModel function should look like? I tried to solve it with scopes, but couldn't find the soultion:
`
@Composable
inline fun <reified T : ViewModel> NavBackStackEntry.sharedViewModel(
navController: NavController
): T {
val navGraphRoute = destination.parent?.route ?: return koinViewModel()
val parentEntry = remember(this) {
navController.getBackStackEntry(navGraphRoute)
}
val scope = rememberUpdatedState(KoinJavaComponent.getKoin().getScope(parentEntry.id))
return scope.value.get<T>()
}

`

Ответить
Kristin Veck
Kristin Veck - 25.07.2023 20:17

Thank you for this video. Sharing the view model between the screens in the nested graph was EXACTLY what I was trying to figure out.

Ответить
Mr boi
Mr boi - 20.07.2023 00:01

Why would you need the helper function if you use dependency injection and already have a instance of the viewmodel created?

Ответить
Lucien Durand-Hardy
Lucien Durand-Hardy - 23.06.2023 12:11

Thanks for the video, you rock. Very efficient.
I didn't find a good practive to navigate from the view model.

For example, on the login screen, when you click on the login button, it will trigger a flow that emit loadings ui state then a success state at the end, how to navigate then?
- sol 1 : pass a nivagateTo...() lambda function to the @composable screen and check the state in the @composable screen (when uistate is Success, navigateTo...())
- sol 2 : pass a lambda function to the view model and call it from there
- sol 3 : the third and best solution

Any idea to achieve that properly?

Ответить
LEE JI HUN
LEE JI HUN - 23.06.2023 11:19

The video is good, but it's a bit of a shame not to check the results

Ответить
Chris Athanas
Chris Athanas - 14.06.2023 05:01

I fixed this example and added UI elements, the PR is available in Philitps' Repo for this video

Ответить
Ahmad R. H.
Ahmad R. H. - 02.06.2023 13:31

i searched everywhere for this and your videos always helped me, thank you!

Ответить
Freediving Trainer
Freediving Trainer - 02.06.2023 02:40

btw standard jetpack navigation for Compose just is pain

Ответить
ngomde cadet kamdaou
ngomde cadet kamdaou - 30.05.2023 12:48

Right at the best moment. Thanks, Philipp, you are amazing!

Ответить
umair abdullah
umair abdullah - 29.05.2023 19:04

I use a different approach when I want to use a shared view model and have no more than two screens.

1. Create an enum class and a compose mutableState variable using that enum. Dont forget to wrap it in remember block.

2. Declare a when condition passing in that variable and calling your screen composables based on the changing value of the state variable.

3. Change the state in callback lambdas on however you want to navigate through screens.

Edit:-

4. You can use BackHandler composable to redirect system Back button callback to your Composables callback lambdas.

Ответить
Alon Shlider
Alon Shlider - 27.05.2023 22:38

Didn't you say your going to use the destinations library going forward instead of the awful accompanist one?

Ответить
Guru Studio
Guru Studio - 26.05.2023 14:15

Hi, Is there any library or sdk that can help to measure a distance from object. not asking for measure a object.
for example: how do i know how far i am from a particular object
if you have any suggestion let me know

Ответить
chummy
chummy - 25.05.2023 23:12

You can popUpTo(0) or other id or route that your app doesn’t have to remove all the backStack

Ответить
Norayr Movsisyan
Norayr Movsisyan - 25.05.2023 09:58

Hi Philipp. Thank you for great video. Hope we will see such a videos too long time.

Ответить
Vicked Vuljo
Vicked Vuljo - 25.05.2023 08:07

How would you handle the case when start destination of the graph accepts optional arguments, since you are navigating to "auth" and not, lets say, login?email={email}

Ответить
Drideon Ng
Drideon Ng - 25.05.2023 04:24

Need your with an android studio project but can't find your email in the about section. Please

Ответить
Xavier Rispal
Xavier Rispal - 24.05.2023 22:16

Quite interesting video !! Thanks for that. Does it mean you don't use anymore this dependency (raamcosta/compose-destinations) in your projects ?

Ответить
Corneliu Bejan
Corneliu Bejan - 24.05.2023 21:43

Hi Philipp! How to prevent involuntary recomposition ? 1) Same "fragment" on the screen many recomposition 2) When i navigate to other screen all prev screens recompose . Is this ok ? Can you please provide any fix usign states (HomeState like in your videos ) ? Thanks

Ответить
Narazgul
Narazgul - 24.05.2023 21:22

Wie gewohnt toller Content der mir direkt wieder weiter hilft! Noch ein kleiner Verbesserungsvorschlag: Eine Grafik, die den gesamten Prozess schematisch darstellt kann hier wohlmöglich noch für weitere Klarheit sorgen. Ich persönlich würde vermutlich auch jedem Nested Graph seine eigene file geben, da es in größeren Programmen für mich schnell unübersichtlich wird. Dann kann man schon in der Ordnerstruktur ablesen, welche Graphs es gibt. Wohlmöglich korrelieren die dann sogar mit Feature Modulen und helfen bei der Übersicht über das Projekt ✌

Ответить
Tousif Javed
Tousif Javed - 24.05.2023 21:19

Update all the playlists
Add your recent videos to the corresponding playlist
I will be helpful for beginners like me to understand all the topics

Ответить
Eric Wathome
Eric Wathome - 24.05.2023 20:25

I was really thinking of implemetning this in a project I'm working on. Thanks for this man

Ответить
4YT only
4YT only - 24.05.2023 20:02

How about a video where you show us how to properly update all dependencies in gradle!? :)

Ответить
purplehazer
purplehazer - 24.05.2023 19:03

What about navigation between screens with topbar + bottomNavBar and full-size screens? Full size screens might be located in another NavHost which is 'above' the NavHost with screens with top-bottom bars. But then, how would it be possible to navigate from parent NavHost to child NavHost?

Ответить
Lakshmana Chilukuri
Lakshmana Chilukuri - 24.05.2023 18:57

Hi can you do a video on toolchains? Very confusing topic.

Ответить
Dïkėñ MhRź
Dïkėñ MhRź - 24.05.2023 18:44

How does this work with deeplink?

Ответить
Lorenzo Suarez
Lorenzo Suarez - 24.05.2023 18:33

Nice video! 🚀

Ответить
Sebastian Seno
Sebastian Seno - 24.05.2023 17:27

Nice video as always,

Ответить
Land of coding
Land of coding - 24.05.2023 16:33

Very informative and helpful tutorial

Ответить
Nicky Larson
Nicky Larson - 24.05.2023 16:05

It would be great if it was illustrated with a sample demo

Ответить
Taslim Hartmann
Taslim Hartmann - 24.05.2023 15:50

Hi Philipp, could you share how to go to specific screen in other nested graph from another nested graph?

Ответить
Sanjar Suvonov
Sanjar Suvonov - 24.05.2023 15:02

Hi Philipp, please show us navigation with bottombar(bottom navigation view). It has two navGraph. Managing these is a problem. Make a video about it.

Ответить
Stoyan Vuchev
Stoyan Vuchev - 24.05.2023 14:41

Just on time for another great guide! I was not aware that it is possible to pop the whole navigation graph using the graph route. I've been using the start destination route for poping the back stack the whole time. 😅

Ответить
BaBaK Raufi
BaBaK Raufi - 24.05.2023 14:27

Good

Ответить
Fazalul Abid
Fazalul Abid - 24.05.2023 14:16

Great as always

Ответить
Raghav Aggarwal
Raghav Aggarwal - 24.05.2023 14:10

Hi Philipp, though I understood the whole video and it's context but I just think it would have been a little better if you could have added some pictorial demonstration of the navigation which you are taking as an example. Great content as usual!

Ответить