Nested Navigation with Bottom Bar and Jetpack Compose | Android Studio Tutorial

Поділитися
Вставка
  • Опубліковано 15 жов 2024

КОМЕНТАРІ • 151

  • @Gtry-pc1bg
    @Gtry-pc1bg 2 роки тому +14

    Omygod, You really explain my number 1 problem for the last 2 months. You really are great

  • @milanglisic7663
    @milanglisic7663 Рік тому +2

    Pa ti si nas! Auu jebote, najaci smo. Hvala ti na ovome tutorijalu. Samo napred!

  • @AiGirlzzandBoyzz
    @AiGirlzzandBoyzz 5 місяців тому

    Thank you so much , I've been stuck in this part for over a week and finally I found your video .

  • @dusanperic
    @dusanperic Рік тому +1

    Hvala brate, baš mi je ovo trebalo, imaš odlične videe o Jetpacku, samo tako nastavi!

  • @shubhanshusharma5372
    @shubhanshusharma5372 Рік тому

    I dont comment usuallly but this video help me in my many projects i always watch this video and your code . Thanks for this video

  • @AliAhmad-dev
    @AliAhmad-dev Місяць тому

    This was a problem for me, but now it is easy. Thank you

  • @rahulchandrabhan
    @rahulchandrabhan Рік тому

    such a perfect playlist for understanding jetpack compose navigation. Thank You

  • @wuguo755
    @wuguo755 Рік тому +1

    Great Job! Thank you very much! I am your student for learning jetpack compose from the beginning! Obvious and beneficial explanation. Expect more videos in the future!

  • @frax84
    @frax84 2 роки тому

    I've been one of the "many messages asked me for". Thank you very much for this nice feedback :)

  • @mungai7534
    @mungai7534 Рік тому

    Was just looking for this, thanks!

  • @adjimaingame
    @adjimaingame Рік тому +1

    Thank you for the tutorial! I've implement this navigation bottom bar with nested navigation on my project. But I'm having trouble. While on the Home Screen, the bottom bar keeps recomposing. I noticed it when elevation kept blacking out and logcat kept showing the message "The application may be doing too much work on its main thread.". My application also became very heavy. Do you have a solution regarding this?

  • @mraja6654
    @mraja6654 11 місяців тому +1

    Really awesome 🎉

  • @chil1t0
    @chil1t0 9 місяців тому +1

    Hi, Stevdza, now that jetpack compose has a different way to handle the BottomNavigation with a rename and refactor of the composable as BottomBar, the function extension RowScope.AddItem doesn't work properly because the class BottomNavigationItem doesn't exist anymore, is there a fix to that?

    • @Sadiqueeeeeeee
      @Sadiqueeeeeeee 7 місяців тому

      I agree. In his last video on bottom navigation, I was encountering the same problem. Better use NavigationBar and NavigationBarItem from material3 in place of BottomNavigation and BottomNavigationItem

    • @cufflink919
      @cufflink919 5 місяців тому +1

      @@Sadiqueeeeeeee This also fixed my issue with the dark theme icons not showing. Thank you!

  • @bedresamarth
    @bedresamarth 3 місяці тому +1

    I had a question. How do you go back to the authNavGraph if I log out from the homeNavGraph?? Kindly give me advice on this as I am stuck

  • @tunahanbozkurt9516
    @tunahanbozkurt9516 Рік тому +1

    How can we achive same behaviour by using xml ? I couldn't find any example. Should I use multiple NavHost Fragments ?

  • @zakariajawas
    @zakariajawas 2 роки тому +1

    This is very helpful, but i have a question how to go from Home to Auth again incase of Logout ?

  • @vitalijuskolinko9011
    @vitalijuskolinko9011 2 роки тому

    Thanks a lot! I am gonna try to implement such navigation for my project in the near future. Your video gonna help me a lot )

    • @StevdzaSan
      @StevdzaSan  2 роки тому

      I'm counting on that! 🙌

  • @hohoday2664
    @hohoday2664 2 роки тому

    Really Fxxk nice I love you Stevdza-san !!!
    I really need this viedo thanks!!

  • @druom69
    @druom69 8 місяців тому

    Приятно слушать! Спасибо за видео

  • @akpapps5988
    @akpapps5988 Рік тому +3

    How to implement a logout from the profile in the bottom nav screen? It has a different controller. And auth in other controller. Then how to navigate?

    • @mauliktogadiya2500
      @mauliktogadiya2500 Рік тому

      same question..found anything???

    • @fi8er1
      @fi8er1 Рік тому

      @@mauliktogadiya2500 ??

    • @ArturoDevA
      @ArturoDevA 5 місяців тому

      solutions is use a lamdda , from HomeScreen to RootNavGraph, works perfect

    • @nuralijakipov3585
      @nuralijakipov3585 Місяць тому

      @@mauliktogadiya2500 did you fing the answer to this question?

  • @mattiapavese4465
    @mattiapavese4465 Рік тому

    that was very useful, thank you!

  • @mouzamali2940
    @mouzamali2940 Рік тому

    Great explanation

  • @trekimpossible2850
    @trekimpossible2850 Рік тому +3

    Since HomeNavGraph is a nested navigation, it could be implemented with navigation extension function. May I know the reasoning to use NavHost?

  • @andrewbeechey7246
    @andrewbeechey7246 Рік тому

    Hi, great video, it has inspired me to investigate jetpack compose navigation in my current app using BackdropScaffold, sadly i cannot work out how to make the backdrop and toolbar disappear when the user navigates to my sub graph. I cannot see how to use your approach of conditionally displaying the bottom nav and applying that to hiding the entire backdrop. please help me if you have time :D

  • @DavidBrunk-l9i
    @DavidBrunk-l9i Рік тому +2

    how would you then navigate back to the auth graph, say for a logout button that was pressed in the home graph?

    • @soheiboz522
      @soheiboz522 6 місяців тому

      did find the solution ?

    • @ArturoDevA
      @ArturoDevA 5 місяців тому

      @@soheiboz522 solutions is use a lamdda , from HomeScreen to RootNavGraph, works perfect

  • @albertomunoz4469
    @albertomunoz4469 2 роки тому +2

    Thanks a lot for all the series on Compose navigation! I have a question, if i want to navigate back from the nested NavHost / NavController with the Bottom Bar to the previous (back to the NavHost / NavController for the Login) , but not using the back hard button but with a clickable in the "HOME" Text for example, how would it be the code inside this clickable { ... } ? I still wasn't able to make it work. Great work and thanks again!

    • @albertomunoz4469
      @albertomunoz4469 2 роки тому +2

      I'm passing the parent NavHostController to the nested one and used it to navigate + popUp back. That made the trick. Then passed a "onNavigateBack" lambda and that feels more clean now.

    • @gtry-in8kc
      @gtry-in8kc 2 роки тому

      Hello thats what Im trying to solve now. So you mean is from RootNavGraph you will pass the NavController to the HomeScreen?

  • @vikashparajuli
    @vikashparajuli 2 роки тому

    Well explained. Thanks for the tutorial.

  • @Fighterkampfer
    @Fighterkampfer 8 місяців тому

    Thank you very much! Just one question, what happens if you want to navigate from the Details screen back to the root graph ? For example, like a "logout" option that must show GRAPH.Authentication again. Will you use the navController at RootNavigationGraph ? And how would you provide it to the details screen ?

    • @meetb26
      @meetb26 7 місяців тому

      one problem show

    • @meetb26
      @meetb26 7 місяців тому

      pass mainNavController in detail page after that mainNavController .navigate(AuthScreen.Login.route)

  • @StevanMedic
    @StevanMedic Рік тому

    Bravo imenjace :) Podrska

  • @_AG8
    @_AG8 Місяць тому

    Once you logged in, how can you delete the main NavGraph backstack so you can't go back to the LoginScreen?

  • @chadisfeir3809
    @chadisfeir3809 6 місяців тому +1

    thank you for this tutorial!
    question: if we have logout button in profile screen where we should navigate to auth graph, don't we need to pass the root navcontroller to main graph in this case ?

    • @ankitkhyalia3194
      @ankitkhyalia3194 6 місяців тому

      Have you found the solution of this?

    • @chadisfeir3809
      @chadisfeir3809 5 місяців тому +1

      @@ankitkhyalia3194 yes just call the auth graph roote using the app navigation and popup the stack

    • @ArturoDevA
      @ArturoDevA 5 місяців тому

      @@chadisfeir3809 please friend share your code

    • @justmeagain9302
      @justmeagain9302 4 місяці тому

      @@chadisfeir3809 will this work even after relaunching the app?

    • @dabdelkarim
      @dabdelkarim 17 днів тому

      @@chadisfeir3809 do you mean something like the following
      fun HomeNavGraph(rootNavController: NavHostController, homeNavController: NavHostController) {
      ......
      ......
      composable(route = BottomBarScreen.Profile.route) {
      ScreenContent(
      name = BottomBarScreen.Profile.route,
      onClick = {
      rootNavController.popBackStack()
      rootNavController.navigate(Graph.AUTHENTICATION)
      }
      )
      }
      I also tried to use homeNavController.popBackStack() instead of rootNavController.popBackStack() but it did not pop the stack!!

  • @thatcrazymf7658
    @thatcrazymf7658 2 роки тому +1

    Hey Stev, you really need to create a video about a nested navigation drawer!

  • @satnamsingh-qh2si
    @satnamsingh-qh2si 10 місяців тому

    Great video for navigation. Can you make videos on how to scope viewmodels to composable in jetpack compose projects?

  • @rakibhasan_
    @rakibhasan_ Місяць тому

    What if I need to navigate from HomeGraph to AuthGraph? Specifically, if I want to log out from the HomeGraph, clear the entire HomeGraph, and then navigate to the AuthGraph, how can I handle this if the NavController used in the HomeGraph doesn't know about the AuthGraph?

  • @caniggiasyabil470
    @caniggiasyabil470 9 місяців тому

    you could achieve such functionality much easier with scaffold and tabrow. The question is how to do it on xml? nice video btw

  • @johanngeisser6109
    @johanngeisser6109 Рік тому

    Thanks, it was very useful

  • @mamhesam
    @mamhesam 2 роки тому

    Thank you so much for your great tutorial. Here,
    if I want the bottom navigation to be shown in the
    graph detail and navigate to the profile item in the
    bottom navigation and navigate to the home item in the profile
    , how can I still be on the information page. Like the bottom navigation
    of the Instagram app. that each bottom navigation item displays the last page.
    Thank you for your answer

  • @vladimirpopov8151
    @vladimirpopov8151 Рік тому

    Thanks a lot. Great explanation of the theme!

  • @cajoncollection3826
    @cajoncollection3826 2 роки тому

    So well explained thanks for putting it up! And I guess the jetpack navigation component will handle the back stack for you? And no need to handle it ourselves if we want to remember the screen navigation?

    • @StevdzaSan
      @StevdzaSan  2 роки тому +1

      Well it's a stable library now, but you'll have to think of how many screens you want to keep in the back stack.

  • @vrindavankiras
    @vrindavankiras 8 місяців тому

    sir what about inner-padding value in scaffold for home , profile and setting screen or what i can do so that not need to pass this innerpadding value to all top label screen?

  • @Anolcera
    @Anolcera 2 роки тому +1

    what if we want to navigate from HOME nav graph back to the Auth ?

  • @bakersbinary
    @bakersbinary 10 місяців тому

    Great, thank you

  • @420Sumanta
    @420Sumanta Рік тому +1

    How to handle duplicate navigation when the user clicks on the same NavigationBarItem twice?

    • @N-fo4nq
      @N-fo4nq 10 місяців тому

      Have you found the solution for that?

    • @420Sumanta
      @420Sumanta 10 місяців тому

      nope. this is really frustrating
      @@N-fo4nq

  • @AndrewDChristie
    @AndrewDChristie 2 роки тому +2

    Thanks!

  • @maqcoders8148
    @maqcoders8148 Рік тому +1

    Thanks for making this video, it means a lot to us. I was looking for the same scenario but found no solution in XML.
    can you please make a video for the same using XML? it will be very helpful for us.
    BTW You did a great job and I appreciate this.
    Thank You!

  • @daniilvladimirov2457
    @daniilvladimirov2457 2 роки тому +2

    A great tutorial as always! Whaiting for your new course, can you give a clue when will it be?)

    • @StevdzaSan
      @StevdzaSan  2 роки тому

      Thanks 👊
      Hmm I will do my best to complete it at the beginning of July 🤔 More information about it, when it's done. 😎

  • @saeedzia5579
    @saeedzia5579 8 місяців тому

    how can i go from home screen to login screen????
    scenario: User logout from setting screen and now i want to open login screen.

  • @moammarqaddafi4858
    @moammarqaddafi4858 10 місяців тому

    Can you please do something like that with XML method without jetpack?

  • @vickramodero6971
    @vickramodero6971 9 місяців тому

    This doesn't work anymore. only a single NavHost per NavController is allowed. So, how do I achieve this?

  • @HariKrishnan-es6po
    @HariKrishnan-es6po Рік тому

    Hi, Stev, How to call a interface method implemented in main activity from composable function.

  • @sinancode
    @sinancode Рік тому

    its very important thanks

  • @marta_na_moto
    @marta_na_moto Рік тому

    Thank you kind soul.

  • @MonichGPT
    @MonichGPT 4 місяці тому +1

    Nested NavHost cause visual bugs in compose 1.7.

  • @HendrawanDev
    @HendrawanDev 2 роки тому

    Clear and well explained tutorial! Btw, i have a case in my android app that similar to the example in this video. So, in my case, the information screen has BottomAppBar component. How i can implement that? Do i need to place the BottomAppBar in parent scaffold? or place it on InformationScreen?

    • @StevdzaSan
      @StevdzaSan  2 роки тому

      I suppose you should place it in another nested graph like you have seen in this video

    • @HendrawanDev
      @HendrawanDev 2 роки тому

      @@StevdzaSan So i have to create another BottomAppBar inside InformationScreen and hide the BottomAppBar from parent? If so, i believe it will works, but the structure of composition will be like this
      Scaffold
      --Content
      ----Scaffold
      ------bottomBar
      is Scaffold inside Scaffold normal?

    • @StevdzaSan
      @StevdzaSan  2 роки тому

      Haven't done that kind of logic yet, so would have to experiment in order to find the best possible solution.

    • @HendrawanDev
      @HendrawanDev 2 роки тому

      @@StevdzaSan the bell already on, waiting for your next video. Keep it up!

    • @thomasgohringer5538
      @thomasgohringer5538 2 роки тому

      @@StevdzaSan Are you planning on making a video on this? I haven't found any resources on how to achieve this behaviour so far.

  • @khumokwezimashapa2245
    @khumokwezimashapa2245 2 роки тому

    Hello. Do you have a video on how to dowload images using glide? I managed to use glide to show my Firebase images in recyclerview, but now I want to download those images into device internal storage.

  • @gamigforgamers
    @gamigforgamers Рік тому

    Amazing video! keep it up

  • @ngomdecadetkamdaou3464
    @ngomdecadetkamdaou3464 2 роки тому

    Awesome, this was helpful

    • @StevdzaSan
      @StevdzaSan  2 роки тому +1

      Glad to hear that buddy 💪

  • @onahchristian2684
    @onahchristian2684 Рік тому

    Just Superb...

  • @maxose
    @maxose Рік тому

    Hi thanks for guide. I faced with problem: how I can pass argument to details navgraph

  • @emmanouilboursalis3912
    @emmanouilboursalis3912 Рік тому

    Hello sir and thank you for the video. May you show as how to pass arguments on nested navigation?
    I am trying to do it on my own but i can't.

  • @TriNguyen-ym3hf
    @TriNguyen-ym3hf 2 роки тому

    I have a question, when i navigate from bottomNavRoute to other Route, callback "OnDestroy" from lifecycle doesn't triggered (only call onStop), and when I navigate back using popBackStack, bottomNav triggers onCreate instead of onStart. That rlly weird, can you tell me what is the problem here, thank.

  • @yahussainmazloom1
    @yahussainmazloom1 Рік тому

    Best Great Job brother

  • @ahamedrizwan2053
    @ahamedrizwan2053 Рік тому

    Nice brother
    Could you create another video demonstrating how to navigate to a specific compose screen when clicking a notification in a nested graph?

  • @eiorajlf
    @eiorajlf Рік тому +1

    how to go back to root nav graph from home nav graph

    • @mauliktogadiya2500
      @mauliktogadiya2500 Рік тому

      Did yo find solution ? What if we have logout like feature and want to clear current graph and navigate to auth graph?

  • @tripabroad8918
    @tripabroad8918 Рік тому

    How to handle case if I don't need to hide bottom bar and want to save tab icon selected?

  • @nuralijakipov3585
    @nuralijakipov3585 Місяць тому

    is it clean code or not?

  • @hasanbestbits
    @hasanbestbits Рік тому +1

    Great video !!!, How did you solve the problem where when you navigate to the details screen and even if you hide the bottom navigation bar it's still visible without the icons and occupies space in the screen ?

  • @nipunshah1373
    @nipunshah1373 2 роки тому

    1 Doubt :
    What is difference between `navigation` & `NavHost` ?

  • @mubashirpa
    @mubashirpa Рік тому

    what should do if i want to log out and go back to login screen?

  • @digvijayshelar8609
    @digvijayshelar8609 Рік тому

    can anyone help me with the thing that bottom bar start destination works but onboarding screen doesnt work due to that

  • @manuelfernandezgarcia2908
    @manuelfernandezgarcia2908 8 місяців тому

    What if i want to open the login screen from the home screen again? Imagine that i logout.

  • @davidavalishvili2768
    @davidavalishvili2768 2 роки тому

    great video. thanks. what about to send custom parcelable arguments from one screen to another?

    • @StevdzaSan
      @StevdzaSan  2 роки тому +1

      I've already made a video about passing a whole object, check my videos.

  • @yossimaskin1393
    @yossimaskin1393 Рік тому +1

    The problem with this approach is that as you mentioned, you have to use separate navControllers and in this case you cannot navigate from the inner graph to the auth graph in cause you need to logout for example. I didn't find a solution to it

    • @BinuJasim
      @BinuJasim Рік тому

      Can't you do a two step routing? First go to the root of the inner graph & then go to the authentication. Does that work?

    • @yossimaskin1393
      @yossimaskin1393 Рік тому +2

      @@BinuJasim I solved this by passing 2 nav controllers to the inner graph, the root one and the other of the bottom navigation but it's a kind of dirty workaround

    • @swiszcz93
      @swiszcz93 Рік тому

      omg i'm having this problemmmmm

    • @BinuJasim
      @BinuJasim Рік тому +1

      @@yossimaskin1393 Fine that works. Another solution is to use a single navcontroller only and define the homescreen graph as an extension function of NavGraphBuilder just like how the authentication graph is defined. This way there is only a single NavHost, so all the navigation information will be available in the navcontroller backstack. You can navigate to any route as well.

    • @krishnankv7894
      @krishnankv7894 9 місяців тому

      ​@@yossimaskin1393 can u please share the details am facing that same problem

  • @francoisrochefort5759
    @francoisrochefort5759 2 роки тому

    Very nice thank you

  • @kannanramakrishnan3052
    @kannanramakrishnan3052 Рік тому

    thank you

  • @javasync
    @javasync 2 роки тому

    Thank you so much!!!!

  • @JohannGeisser-d9m
    @JohannGeisser-d9m Рік тому

    Excellent, but I can not seem to navigate again from Home screen to AuthGraph

  • @progdeelite
    @progdeelite 2 роки тому

    Super nice and well explained. #top

  • @ApratimArora
    @ApratimArora 2 роки тому +1

    How can i achieve this without jetpack Compose? I still build apps using XML layout and kotlin. Kindly suggest me some article or youtube video..

  • @ovedgustavorinconmachado506
    @ovedgustavorinconmachado506 5 місяців тому

    Why is slower my app in compose than in xml?

  • @AbdallahMehiz
    @AbdallahMehiz Рік тому

    having multiple navigation graphs results in a lot more boiler plate and more points of failure, current compose navigation is by all means, not ready for production

  • @cuiteleo
    @cuiteleo 2 роки тому +3

    Best

  • @roonyshekho8067
    @roonyshekho8067 2 роки тому

    How can I change the background color of a bottom navigation screen?

    • @zakariajawas
      @zakariajawas 2 роки тому +1

      pass backgroundColor to the BottomNavigation()

    • @roonyshekho8067
      @roonyshekho8067 2 роки тому +1

      @@zakariajawas I meant the screen not the bottom navigation itself. It can be changed using background color attribute in scaffold.

  • @olukayodepaul7070
    @olukayodepaul7070 2 роки тому

    You are bless.....

  • @jopadjr
    @jopadjr 2 роки тому

    184th...I am a subscriber of your Udemy courses and nice to see your YT videos here.

  • @andikitta9480
    @andikitta9480 2 роки тому

    how to logout?

    • @StevdzaSan
      @StevdzaSan  2 роки тому

      Logout what? 🤔

    • @andikitta9480
      @andikitta9480 2 роки тому

      @@StevdzaSan after press login button, we enter to the mainscreen, so my question is, how to logout back to the authentication screen from the mainscreen?

    • @StevdzaSan
      @StevdzaSan  2 роки тому

      @@andikitta9480 Well if you pop the Authentication graph of the backstack, you can just explicitly navigate to that same graph again with navigate function.

    • @StevdzaSan
      @StevdzaSan  2 роки тому

      And you can create the logic to dynamically calculate whether to show Home graph or Auth graph as a start destination based on the value saved in the app preferences for example. Bottom line, there are multiple ways...

    • @renanboni7636
      @renanboni7636 2 роки тому

      @@StevdzaSan there are multiple ways, could you please elaborate one? neither of what you said above will work, thank you

  • @AndrewDChristie
    @AndrewDChristie 2 роки тому

    Thanks!