Compose Navigation Just Got SO MUCH EASIER 😱

  Рет қаралды 64,494

Philipp Lackner

Philipp Lackner

2 жыл бұрын

The Jetpack Compose navigation library had quite some issues and annoying things. It uses routes to navigate and all the parameters passed to these routes needed to be strictly defined, retrieved and passed. Also, passing parcelables wasn't possible.
With the Compose Nav Destinations library it is now possible! In this video I show you how.
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/premium-courses...
💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:
elopage.com/s/philipplackner/...
Check the library here:
github.com/raamcosta/compose-...
Check Rafael's Medium article for more details:
/ compose-destinations-s...
Subscribe to my FREE newsletter for regular Android, Kotlin & Architecture advice!
pl-coding.com/newsletter
Join this channel to get access to perks:
/ @philipplackner
Get the initial source code for this video here:
github.com/philipplackner/Com...
Get the final source code for this video here:
github.com/philipplackner/Com...
Regular live codings on Twitch:
/ philipplackner
Join my Discord server:
/ discord
Regular programming advice on my Instagram page: / _philipplackner_
Checkout my GitHub: github.com/philipplackner
You like my free content? Here you can buy me a coffee:
www.buymeacoffee.com/philippl...

Пікірлер: 217
@shawnf3495
@shawnf3495 2 жыл бұрын
This library is amazing, but what's even more amazing is what Rafael used to create it. Kotlin Symbol Processing or KSP is "an API that you can use to develop lightweight compiler plugins. KSP provides a simplified compiler plugin API that leverages the power of Kotlin while keeping the learning curve at a minimum. Compared to kapt, annotation processors that use KSP can run up to 2 times faster. Also, because KSP traces symbol resolutions dynamically, a change in a file is less likely to pollute other files and therefore the set of files to be reprocessed is smaller (that's why it's faster). This is not possible for kapt because it delegates processing to javac. KSP can process Java sources as well. The API is unified, meaning that when you parse a Java class and a Kotlin class you get a unified data structure in KSP." So when you mark your composables with @Destination just know that is the power of KSP not kapt.
@skullkrum20
@skullkrum20 2 жыл бұрын
Completely agree! In fact, some of my features would not be possible with Kapt, at least not without some workarounds :)
@jonneymendoza
@jonneymendoza Жыл бұрын
NICE, please explain this in more depth
@pierre.vieira
@pierre.vieira 2 жыл бұрын
Finally something like this has been released, thanks for sharing!
@ubersticks
@ubersticks 2 жыл бұрын
Thanks for sharing this Philip! I watched your videos using Compose navigation and was disappointed how ugly Navigation had become. It was a step backwards. You didn't make fun of it in the videos, so I thought it was just me. :-) This is beautiful (thanks @Rafael Costa)
@FlorianWalther
@FlorianWalther 2 жыл бұрын
Nice, I actually used his approach in my live streams (without the library tho) Thanks again to Rafael for his help!
@skullkrum20
@skullkrum20 2 жыл бұрын
No problem Florian, it was my pleasure! :)
@AmitJayant
@AmitJayant Жыл бұрын
@@skullkrum20 Thank you for this library
@pratikchauhan8175
@pratikchauhan8175 2 жыл бұрын
What a great library makes the work easier and cleaner Thanks 👏
@JohnDoe-wx3zm
@JohnDoe-wx3zm 2 жыл бұрын
Thank you Philipp for making this video, and thank you YT algorithm for recommending it to me! At least that's one thing Google did correctly...
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Glad it was helpful!
@vengateshm2122
@vengateshm2122 2 жыл бұрын
Thanks Phillip for sharing.
@jatinvashisht4293
@jatinvashisht4293 2 жыл бұрын
Yeah not able to pass parcelables were such a pain
@vedx
@vedx 2 жыл бұрын
Awesome library. I have been using this. 👌🏻
@sovrinfo
@sovrinfo 2 жыл бұрын
Thank you a lot!
@zafar_codes
@zafar_codes 2 жыл бұрын
Great, thanks 🔥🔥🔥
@mustafaammar551
@mustafaammar551 2 жыл бұрын
very cool library thank you
@jaidynbelbin4863
@jaidynbelbin4863 2 жыл бұрын
This looks amazing! Not being able to pass an actual object through the route was such a strange thing to discover coming from SwiftUI and Flutter. Will you migrate to this in your Android Twitch Network series?
@PhilippLackner
@PhilippLackner 2 жыл бұрын
In case you missed my recent updates regarding that on Instagram - there will be no further streams on Twitch for the 2 main reasons: 1. All the functionality of the social network app that we wanted is done 2. It's extremely difficult to learn, concentrate on coding and entertain an audience who watches your stream. If any of these points lacks this immediately results in a significantly lower number of people who watch the stream. That demotivates over time. So in short, I don't enjoy it anymore and think it's more win-win if I instead make youtube videos which reach more people and at the same time are a lot more fun for me.
@nithinraj07
@nithinraj07 2 жыл бұрын
Amongst the few members who is a follower of your SocialApp project, it helped me a lot in building huge app and I used to constantly go back to the project repo and learn how you have implemented a certain thing. Usually the projects that are available in docs to refer to are either too old or non intuitive It’s sad that you are discontinuing the series. But anyways, looking forward for more content !
@PhilippLackner
@PhilippLackner 2 жыл бұрын
@@nithinraj07 glad you enjoyed it and thanks for watching!
@shahidzbi
@shahidzbi Жыл бұрын
Damn Man Rafael u r an angel What a solution ❣
@garrisonsnow7776
@garrisonsnow7776 Жыл бұрын
Do you use still use this library in your projects? It's been a year now just wondering
@flowzk921
@flowzk921 2 жыл бұрын
wow this is super cool, now one can pass actual objects!
@gauravkumar-bs3pf
@gauravkumar-bs3pf Жыл бұрын
I am unable to generate the classes after rebuilding the project. how can I resolve this problem?
@brianryan4053
@brianryan4053 2 жыл бұрын
Rafael is genius.
@safionweb
@safionweb Жыл бұрын
Hey, Philipp! Thanks for this amazing video. Has Google come up with a better solution as of yet? Or should we use this 3rd library?
@skullkrum20
@skullkrum20 Жыл бұрын
No new solution from Google as of now. 🙂
@Siva-vn1wo
@Siva-vn1wo Жыл бұрын
can we use this in bottom navigation?
@tigranavdalyan900
@tigranavdalyan900 Жыл бұрын
how to implement nested navigation graphs in this library?
@eslamhamdi5712
@eslamhamdi5712 2 жыл бұрын
👏 Amazing, you are a life saver
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Happy to help!
@marekmisik7278
@marekmisik7278 2 жыл бұрын
great, but could you make a bluetooth example with compose by any chance?
@rma1563
@rma1563 Жыл бұрын
It does not identify "NavGraphs.root" in "DestinationsNavHost(navGraph = NavGraphs.root)" anymore. Any help please?
@junlapunete1602
@junlapunete1602 7 ай бұрын
Is that library can support nested navigation?
@tonnie7079
@tonnie7079 2 жыл бұрын
Hi Philipp, Have followed the lecture but I am wondering if you use Compose Destinations, where does that leave the theme?Since you have moved the screen composables out of the Main Activity, how then do you theme the app?
@skullkrum20
@skullkrum20 2 жыл бұрын
That is not different than without the library 🤔 You still have the Theme in the same place (just like he has on the video). All screens will still be themed with it!
@tonnie7079
@tonnie7079 2 жыл бұрын
@@skullkrum20 Thx for clarifying
@yousefbeiruty6417
@yousefbeiruty6417 Жыл бұрын
How could I implement a navigation drawer or bottom navigation using this library 🤔
@manuelduarte8880
@manuelduarte8880 2 жыл бұрын
what is the name of the theme you use in the IDE
@thegreatwarrior4989
@thegreatwarrior4989 2 жыл бұрын
You made my day ✊✊✊👍👍👍
@moheltanani1036
@moheltanani1036 Жыл бұрын
What an amazing library. I love it, I just have one concern. So, I was told before by boos not to use third party library for our app (which is a release app published on store) because incase one day support stops for such library then our app will not be functional anymore. So, what are your thoughts about this subject using this library? Like, is the library dependable enough to use in released apps? or I should stick with native compose? Your replies are much appreciated!
@jonneymendoza
@jonneymendoza Жыл бұрын
Swhat if the originl author abandons it? doesnt meanan that the library is deleted off your project all of a sudden
@firstnamelastname-oy7es
@firstnamelastname-oy7es Жыл бұрын
@@jonneymendoza If the dev stops active support for this library, then In the future, after a bunch of android and google updates, the library might not work anymore because files and other things in the OS are moved into different places and functions may get renamed or deprecated in other ways. Also the original author of the third party library may pull the code offline one day, or may be forced to if they used code in their library form another library that they didn't have the rights to. It could also be a security issue if you don't go over the whole source code of the third party library before using it, and every time there is an update to the library. It can get complicated fast. If all the code is your own, then you don't have to worry about those issues. If the boss says not to use it, then I guess you have to do what the boss says. It sucks but what can you do? If the boss finds out the app doesn't work correctly or has security issues in the future because an employee did something the boss said explicitly not to do, it might cost that employee their job.
@jonneymendoza
@jonneymendoza Жыл бұрын
@@firstnamelastname-oy7es even Google abandons there libraries
@jatinvashisht4293
@jatinvashisht4293 2 жыл бұрын
Can we still get navigation arguments from saveStateHandle in view model like in compose navigation?
@skullkrum20
@skullkrum20 2 жыл бұрын
Yes Also in a type-safe way! val myArgs = MyScreenDestination.argsFrom(savedStateHandle)
@jatinvashisht4293
@jatinvashisht4293 2 жыл бұрын
@@skullkrum20 wow, that's really nice, thanks for the library 🙏
@amineayachi335
@amineayachi335 2 жыл бұрын
thanks so much
@KotlinBek
@KotlinBek Жыл бұрын
that would be awesome if you talk a bit more about back Stack. yeah great video btw
@abada-s
@abada-s 2 жыл бұрын
Wooow this is amazing
@valtteri_its_james
@valtteri_its_james Жыл бұрын
Maaan, this library is legendary !!!
@siddheshpalkar3986
@siddheshpalkar3986 Жыл бұрын
Could you please make a video on how we can add the transition to this library?
@gadeern1586
@gadeern1586 2 жыл бұрын
Thank you for the amazing video!! could you please do a video about how to use this navigation library with a top app bar (with dynamic titles and icons) 😢
@skullkrum20
@skullkrum20 2 жыл бұрын
Very similarly to how you can do it in normal compose navigation 🙂 You should use a Top level Scaffold wrapping the DestinationsNavHost. Then call currentAppDestinationAsState and change toolbar when destination changes 🙂
@techmarinar
@techmarinar Жыл бұрын
Thank you very much , but we need you to make a video of Bottom Bar navigation with this awesome library (raamcosta )
@KingFuYouTube
@KingFuYouTube 2 жыл бұрын
How would this library work with bottom navigation and can it prevent 1 screen from stacking up if reselected repeatedly?
@skullkrum20
@skullkrum20 2 жыл бұрын
It would work the same way as with normal compose navigation. To prevent screens from stacking up, you need to use launchSingleTop when navigating :)
@KingFuYouTube
@KingFuYouTube 2 жыл бұрын
@@skullkrum20 Thanks for replying I will test it out.👍
@skullkrum20
@skullkrum20 2 жыл бұрын
@@KingFuKZfaq Let me know how it goes!
@saeedsharif2463
@saeedsharif2463 Жыл бұрын
sir hwo we use this with bottom navigation
@xavierrispal9605
@xavierrispal9605 2 жыл бұрын
Awesome !! Could be nice to check how this library can work along with accompanist-navigation-animation :-D
@skullkrum20
@skullkrum20 2 жыл бұрын
It already works! You can check more details in the Readme and wikis 😁
@siddheshpalkar3986
@siddheshpalkar3986 Жыл бұрын
Please let me know if you find a way to add a transition in this library..
@siddheshpalkar3986
@siddheshpalkar3986 Жыл бұрын
@@skullkrum20 Please let me know if you find a way to add a transition in this library..
@skullkrum20
@skullkrum20 Жыл бұрын
@@siddheshpalkar3986 it’s already done!
@asadullahilyas
@asadullahilyas Жыл бұрын
How can we implement this with Bottom Navigation Bar? I tried something but as soon as I press a button in Bottom Navigation Bar, whole screen, including the Bottom Navigation Bar, is changed to new destination.
@skullkrum20
@skullkrum20 Жыл бұрын
It’s really not that different than with official compose navigation. You can check the documentation website and search for it, you’ll easily find the example 🙂
@Warrynt
@Warrynt 2 жыл бұрын
omg thank you so much
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Happy to help
@jehandadkamal9637
@jehandadkamal9637 11 ай бұрын
How can we override Deeplinks?
@allanandliftedhands2669
@allanandliftedhands2669 2 жыл бұрын
I love this..my only confusion is wether i should start learning and using this right away..or perfect the previous way first..is it advisable to learn the previous way first or i should jump right into this..? Any help is appreciated.
@PhilippLackner
@PhilippLackner 2 жыл бұрын
IMO you should understand how Compose navigation works generally. But once you feel comfortable with the basics, feel free to use this
@allanandliftedhands2669
@allanandliftedhands2669 2 жыл бұрын
@@PhilippLackner thanks a lot that really has helped.
@skullkrum20
@skullkrum20 2 жыл бұрын
This is basically the same thing if you asked "Should I learn manual dependency injection before using Hilt/Dagger?". The answer is, you should at least understand what Dependenc injection is and have a general idea of how you would implement it manually. So yeah, like @Philipp said, try to understand the basics, then don't worry if you don't understand EVERYTHNG :)
@sjavokhir
@sjavokhir 2 жыл бұрын
Why doesn't "Join" button appear on my KZfaq app?
@tiltedbybox6118
@tiltedbybox6118 2 жыл бұрын
Is conditional start destination possible? For example Non auth. user - after splashscreen immediately goes into login/register destination Authenticated user - splashscreen stays visible while data is being fetched and then user is redirected to Home destination. It was a bit tricky for me to get this working with xml nav component and the splashscreen api, but at the end it turned out quite good. So I'm wondering if I can easily migrate this part to compose.
@skullkrum20
@skullkrum20 2 жыл бұрын
Yes, you can use override the start destination on the annotations at runtime when you call DestinationsNavHost.
@xephosbot
@xephosbot Жыл бұрын
I am now faced with this. Did you find any solution? I'm trying to check on the Login screen if the user is logged in and go to the main screen. But it still causes a little flash
@eugenewainaina5626
@eugenewainaina5626 3 ай бұрын
Chris P Bacon, lol. The lil pig. W reference
@BuildItCreative
@BuildItCreative Жыл бұрын
Why not use this library in newest video..?
@venkatesh4307
@venkatesh4307 2 жыл бұрын
Super cool
@azuolassaulius938
@azuolassaulius938 2 жыл бұрын
Epic. But can i use this library if I'm developing app where i don't want the code to be open source?
@skullkrum20
@skullkrum20 2 жыл бұрын
Of course! It's just like any other library. You get the dependency from maven central and that's it. Don't need to worry about that :)
@arfinhosain
@arfinhosain 2 жыл бұрын
finally you changed the theme
@zakmiltan
@zakmiltan Жыл бұрын
Hi Philip Have you ever manage to do a mix match with the conventional google navhost or with this KSP one , to have a bottonsheet modal support , without crashing the app due to 2 different navhost has different startDestination, I get like an error like this"ViewModelStore should be set before setGraph call"
@zakmiltan
@zakmiltan Жыл бұрын
Answer to my question id does I've just done a test project , This library should be in the official google package, this not just simple but has a full support to have a bottomsheet navigation without changing the navhost root and it wont crash , thanks Rafael for this amazing enhancement.
@sublimecoder
@sublimecoder Жыл бұрын
You need to use different navcontroller object for different navhost 😅
@sinandinc8607
@sinandinc8607 2 жыл бұрын
hey philip thanks for video also could you make a video about to modular architecture
@PhilippLackner
@PhilippLackner 2 жыл бұрын
I'm working on a big course that will come out this month
@sinandinc8607
@sinandinc8607 2 жыл бұрын
@@PhilippLackner oh thanks ı'm so glad to hear
@serhiiostrovskyi4387
@serhiiostrovskyi4387 2 жыл бұрын
Looks great, however what if I want to share a viewModel between destinations?
@xectrone
@xectrone Жыл бұрын
Same question did you find any solution?
@EverythingWithKotlin
@EverythingWithKotlin 2 жыл бұрын
hello there .. your tuts are amazing .. can i request to make a full jpc apps with multi modular please ?
@ChrisAthanas
@ChrisAthanas 2 жыл бұрын
Incredible
@RadhakrishnanNaik
@RadhakrishnanNaik 2 жыл бұрын
any idea, how to pass `arguments: List` and `deepLinks: List` to the navhost composable with this library
@skullkrum20
@skullkrum20 2 жыл бұрын
The whole idea is: you don’t need to. 🙂 NavArguments get inferred from the annotated composable arguments and you use a parameter on Destination annotation to define your deep links. Check the repo, it has link to documentation
@RadhakrishnanNaik
@RadhakrishnanNaik 2 жыл бұрын
@@skullkrum20 Thank you
@tanaygupta6905
@tanaygupta6905 2 жыл бұрын
Hey, can you tell which theme you are using? 🤩
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Xcode theme
@muhammadtalhaakbar826
@muhammadtalhaakbar826 2 жыл бұрын
How to give viewModel as argument to root screen. I have a screen which contains navDrawer and I want to navigate to other screens inside the content of navDrawer.
@skullkrum20
@skullkrum20 2 жыл бұрын
Hey 👋 The nav drawer is not part of any screen. It is part of Scaffold that you use on top level Composable. To navigate in that top level composable, you take the NavController you pass to DestinationsNavHost and use the navController.navigate(Direction) extension function. Also, the top level Composable that contains the Scaffold is not related to Compose Destinations since it is not a Destination (you don’t annotate it with it). So you access viewModel directly through the methods available like “viewModel” or “hiltViewModel” or whatever way you usually get view models 😅
@Rafael-hk9pg
@Rafael-hk9pg 2 жыл бұрын
Great video! How can you implement a conditional startdestination?
@skullkrum20
@skullkrum20 2 жыл бұрын
Hi Rafael! Great name btw :D You can pass a start destination when calling DestinationsNavHost, just as you could do before.
@Rafael-hk9pg
@Rafael-hk9pg 2 жыл бұрын
@@skullkrum20 haha thanks!
@luckydevil1601
@luckydevil1601 Жыл бұрын
Does it affect performance negatively? If not, then it's incredible!
@PhilippLackner
@PhilippLackner Жыл бұрын
Nah, it uses the normal navigation, but just exposes functionality that's easier for us to deal with
@Ryan-ff2db
@Ryan-ff2db 2 жыл бұрын
This is the second most awesome thing I've ever seen.
@skullkrum20
@skullkrum20 2 жыл бұрын
Thanks Ryan 🙂
@Ryan-ff2db
@Ryan-ff2db 2 жыл бұрын
@@skullkrum20 Thank You.
@denisk3852
@denisk3852 2 жыл бұрын
How about animations between screens? Thank you!
@skullkrum20
@skullkrum20 2 жыл бұрын
Look in the documentation website under “styles and animations” > “animated style”. Don’t forget the setup section below that as well.
@swiffty1
@swiffty1 2 жыл бұрын
How do you pass in a DestinationsNavigator for use in a composable. E.G MainActivity contains a composable and I want to ass in an implementation of DestinationsNavigator to it
@skullkrum20
@skullkrum20 2 жыл бұрын
I'm not sure I understand your use case. If you're talking about navigation that happens out side any specific screen, you should use NavController. DestinationsNavigator is only meant to navigate from screen to screen.
@swiffty1
@swiffty1 2 жыл бұрын
@@skullkrum20 Do you mean use the native android NavController not connected to your compose-destinations library? Yes I mean if I wanted to control navigation from MainActivity for example e.g only use NavHostController in MainActivity rather than have the screens control navigation themselves.
@skullkrum20
@skullkrum20 2 жыл бұрын
@@swiffty1 NavController is connected to my library. It is what I used internally inside DestinationsNavigator. You can and should do rememberNavController() and pass the result to DestinationsNavHost. Then you can use navController.navigateTo extension function and your set 🙂
@kingcoder7654
@kingcoder7654 2 жыл бұрын
Amazing
@DerCheckerzeigts
@DerCheckerzeigts 2 жыл бұрын
How would this work with firebase-dynamic links and dynamic routing?
@skullkrum20
@skullkrum20 2 жыл бұрын
How did you solve that with "normal" compose navigation component? Is it through Deep Link? If so, then you can specify deep links in your screens via the annotation, like @Destination(deepLinks = ........)
@DerCheckerzeigts
@DerCheckerzeigts 2 жыл бұрын
@@skullkrum20 I dont know the compose way, but with xml its achievend via deeplinks. So yeah, your approach should work aswell. Thank you!
@skullkrum20
@skullkrum20 2 жыл бұрын
@@DerCheckerzeigts Ok, I wanted to make sure :) Then yeah, this library will be easy to setup for that and actually it will be easier than with xml to work with Deep links in general.
@emmanuelmtali1594
@emmanuelmtali1594 Жыл бұрын
What you have conditional navigation i.e. if logged in home is profile if not login is home
@skullkrum20
@skullkrum20 Жыл бұрын
DestinationsNavHost has a startRoute parameter where you can pass the start you want at runtime.
@asrieltiagokrueger3346
@asrieltiagokrueger3346 2 жыл бұрын
Thanks for sharing this amazing library! Btw, can you make a video about how to handle specific top bars for two or more screens? I'm working in something like these, but i was confusing about having only one Scafold on the MainScreen, that handle the top bars using callbacks, and observing the current screen state. Or the best way is to have a Scafold on every Screen? Example: 1. First screen top bar has a search icon, that can filter something. 2. Second screen has a back button, search icon disappears. 3. Third Screen has a menu button, back button disappears. Maybe this library can already help with that... Another thing, is how to implement a Scrollbar on a LazyColumn.
@Theotoffel1
@Theotoffel1 2 жыл бұрын
one beginner question still is open to me: How can i pass a viewmodel to share it with all composables in this navgraph. passing it as parameter doesn't work
@skullkrum20
@skullkrum20 2 жыл бұрын
Check documentation website and search “share ViewModels”. It will get you there 🙂
@Theotoffel1
@Theotoffel1 2 жыл бұрын
@@skullkrum20 thanks for answer, i will try to make it. For me as beginnen it's Not quote easy to understand. May be because of Lack of knowledge
@emmanuelmtera5936
@emmanuelmtera5936 2 жыл бұрын
I love your native android videos and i really enjoy them , But i was wondering how powerfull kotlin and compose can be so, Can you make a compose app, that tracks (or prevents a phone from being flashed if it is stolen,lost e.t.c)
@crateer
@crateer 2 жыл бұрын
Weird question. But no, you can’t write any user app which does that. Basically impossible. (Before you ask, this has nothing to do with kotlin or compose btw.)
@edwardbaylon4729
@edwardbaylon4729 2 жыл бұрын
How do you pass parameter to the starting composable?
@PhilippLackner
@PhilippLackner 2 жыл бұрын
I can't think of a case where you would want to do that / couldn't do that in a better way
@skullkrum20
@skullkrum20 2 жыл бұрын
You cannot do that even with official compose navigation. Start destinations cannot have mandatory navigation arguments 🙂 Which makes perfect sense btw.
@xectrone
@xectrone Жыл бұрын
@@skullkrum20 shared viewModel
@tcl78
@tcl78 Жыл бұрын
I'm not really a fan of using 3rd party, unofficial libraries in my projects... especially libraries that have their roots so deep into the system. I don't want to find myself in perhaps 5 years or more having to rip apart the whole app because i cannot compile it anymore since an unofficial 3rd party library is being deprecated or doesn't behave correctly with future versions of Android or the official libraries that i already use. This of course has nothing to do with this specific library, but in general. The less you rely on 3rd party libraries, the less bad surprises you are going to have in the future. I really don't want to find myself rethinking and rewriting the navigation of an app i wrote years ago only because i did a bad choice... it is already hard enough to have to work with something YOU wrote years and years ago without even remembering what it was about, how it worked, etc. because your user asked for a new feature in an existing app you build... i don't really want to make this process even more difficult by "betting" that the libraries i used will still exist in a few years from now. So, even if it is painful, I'll stick with the official navigation recommendations from Google and wait for them to come up with an official (and fully supported) solution... and i'm already pissed by the fact that they keep changing how to develop androids apps apparently every few months forcing me to re-learn how to do things i thought were settled over and over again...
@skullkrum20
@skullkrum20 Жыл бұрын
It’s the beauty of our field if you ask me. Things keep evolving and changing and every time there is some detail which is slightly better or easier. It’s also a lot of fun to learn things if you ask me 😉 I understand the fear of libraries. That’s ok, it’s not for everybody. That said, consider this: this will not change the core of your navigation. It is a wrapper to the official APIs. You should be able to easily go to official way if you need to since at the core it’s all the same. Also, I’m never going to stop providing support and updates unless Google comes up with this exact type of solution (and only if it is objectively better in all ways) at which point I would provide a migration path which as I said should really be very easy to follow. So it’s up to you to decide if this potential future migration cost is likely enough or hard enough that you’d rather pay an upfront cost of having to deal with navigation as it is without the library. But I can tell you for sure that the answer is not always yes and it is not always no. It will depend on a lot of factors related with your project setting how good are the developers to do these easy migrations, how big is the project etc etc.
@alexandrereutola3246
@alexandrereutola3246 2 жыл бұрын
What parameter should I use for a screen preview since I have to specify a navigator as argument?
@skullkrum20
@skullkrum20 2 жыл бұрын
EmptyDestinationsNavigator
@alexandrereutola3246
@alexandrereutola3246 2 жыл бұрын
@@skullkrum20 Thank you very much!
@FreedivingTrainer
@FreedivingTrainer Жыл бұрын
NavGraphs not found (app builded). But app bulded and I see generated class UPD: Downgrade gradle plugin to 7.3.0 do the trick. (AS use 8.0.0-alpha for new projects by default)
@rma1563
@rma1563 Жыл бұрын
I have downloaded his project as it is and changed the gradle plugin to 7.3.0 as you have said and it still doesnt work. " unresolved reference : NavGraphs.root ". Any help?
@visvajeet5609
@visvajeet5609 2 жыл бұрын
Is there any performance issue?
@skullkrum20
@skullkrum20 2 жыл бұрын
No. This is all code generation that happens at build time. Other than that, it is code that you could have written yourself, so no performance penalty.
@visvajeet5609
@visvajeet5609 2 жыл бұрын
@@skullkrum20 cool
@samirbasnet9523
@samirbasnet9523 2 жыл бұрын
Can anyone tell me while using this library is it possible to pass data back to previous screen when navigating back? If yes how?
@skullkrum20
@skullkrum20 2 жыл бұрын
It is possible, but it will be just like using normal compose navigation. You have to use navBackStackEntry and put your values there by key. So basically, this library did not do anything in regards to that: all tools available for that are still there, but there are no special help to do that in a safer way. Yet anyway, who knows! :)
@samirbasnet9523
@samirbasnet9523 2 жыл бұрын
@@skullkrum20 Thank you for confirming but i still cannot figure out how to do it. Could you possibly guide me with a bit of example code?
@skullkrum20
@skullkrum20 2 жыл бұрын
@@samirbasnet9523 stackoverflow.com/questions/66837132/jetpack-compose-navigate-for-result
@samirbasnet9523
@samirbasnet9523 2 жыл бұрын
@@skullkrum20 Thanks a lot . Also i found that we can pass parceleable object into composables directly from parameter but if we use @Destination(navArgs=..) it gives error saying 'navArgsDelegate' cannot have arguments that are not navigation types
@skullkrum20
@skullkrum20 2 жыл бұрын
@@samirbasnet9523 Really? I will jump right on it :D Do you mind opening an issue on the github repo?
@John-qt6qk
@John-qt6qk 2 жыл бұрын
Gr8
@jakhongirmadaminov5849
@jakhongirmadaminov5849 2 жыл бұрын
I cannot make it work in a multi module project
@skullkrum20
@skullkrum20 2 жыл бұрын
I am working on a fork of a known Chris Banes project: tivi. In the next few days, I'll be doing a few small changes on Compose Destinations Library to be easier to use in multi-module projects (you can already do it, but I want to try to make it easy). Later I'll make my fork public so everyone can see an example of a multi-module project in practice 🙂 So don't give up on this library yet!
@coocys2143
@coocys2143 2 жыл бұрын
Hey :D This is not about this Topic. More an Video Request. Can you maby do an Tutorial for an Language switcher in the App for all Text Elements. That would be so awsome :D And a Question about this Library. Is it possible that Google will Implement this in Compose themself?
@skullkrum20
@skullkrum20 2 жыл бұрын
> And a Question about this Library. Is it possible that Google will Implement this in Compose themself? It is possible, but at the moment it doesn't seem likely.
@loiseaulucien4373
@loiseaulucien4373 Жыл бұрын
Great video! can you make a follow up video with deeplinks using this library ?
@MatthewSmith-mt3kz
@MatthewSmith-mt3kz 2 жыл бұрын
The library looks simple enough to use, however, I was having some issues combing KSP (for the library) and KAPT (for Dagger Hilt - no KSP support yet) in my project. Just couldn't seem to get the two to play nice together. Order of the plugins made no difference. Otherwise, the library seems to be what we need until the Compose navigation evolves (even if it's just parcelables).
@skullkrum20
@skullkrum20 2 жыл бұрын
That’s weird, I’ve had both hilt and compose destinations at the same time before. There are no reports that I known of of these two not getting along 🤔
@MatthewSmith-mt3kz
@MatthewSmith-mt3kz 2 жыл бұрын
Finally got it working, was mainly incompatibility issues within my project (Kotlin/Gradle/Hilt/Room etc). Anyway, great library, super simple to use. Will admit though haven't converted any of my Dto's to parcelables (yet?), so not passing complex objects (or even lists of those objects, not sure if that's the right way), more just query parameters, key/value pairs etc. Thanks Rafael.
@skullkrum20
@skullkrum20 2 жыл бұрын
@@MatthewSmith-mt3kz Definitely! Do not pass big structures as navigation arguments. The capability is there in case you need to pass small Parcelables around 🙂 Btw, it’s not widely known but even with official compose navigation, you can pass parcelables as nav args. There is even an example of it in Kotlin dsl navigation docs. So all this lib does is making it much easier to do it if you need to 🙂
@sacarymoviesamu
@sacarymoviesamu Жыл бұрын
It's so cool. I like simple things because i'm stupid when programming. Brain go DUUUUUUHHHHHHHH
@visvajeet5609
@visvajeet5609 2 жыл бұрын
How to use it with BottomNavigation? How to read currentBackStackEntryAsState()
@skullkrum20
@skullkrum20 2 жыл бұрын
Same way you do it without this library. You get the navController, pass it to the DestinationsNavHost, and you are free to do anything like before :) The cool part with that is that you can easily get the generated Destination correspondent to the current nav back stack entry too. So you don't need to be comparing routes. You instead compare type-safe constructs like these Destinations.
@ahmedrabie4491
@ahmedrabie4491 2 жыл бұрын
SOrry to say that but the liberary seems to be not working at all, I belive they changed it a lot without adding new dopcumentation or its stop working anyway
@PhilippLackner
@PhilippLackner 2 жыл бұрын
It works perfectly fine for me, also for the latest kotlin version
@skullkrum20
@skullkrum20 Жыл бұрын
Yea absolutely it is working, tons of teams are using it 😊 It also has a docs website that is up to date 🙂
@LEEJIHUN
@LEEJIHUN Жыл бұрын
updated version need
@gauravthakkar802
@gauravthakkar802 2 жыл бұрын
Please share your theme
@Danuel
@Danuel 2 жыл бұрын
Xcode dark theme
@longshin4299
@longshin4299 2 жыл бұрын
Thanks for your video. But I got an issue with ProfileScreenDestination. It's does have user params
@skullkrum20
@skullkrum20 2 жыл бұрын
Hi Long shin. Can you please open an issue on GitHub with more details? Or send me a DM on twitter. I’d love to help out. It’s probably something missing on your side, but I would need more details 🙂
@longshin4299
@longshin4299 2 жыл бұрын
@@skullkrum20 it's about passing scaffoldState. But hopefully I found the your docs. And It's done. But it's take some time to find that
@longshin4299
@longshin4299 2 жыл бұрын
@@skullkrum20 Could you add some usage about that in readme for orthers developer to find it quickly?
@skullkrum20
@skullkrum20 2 жыл бұрын
@@longshin4299 cool. Yes I am trying my best to improve docs but it’s still a long ways to go!
@skullkrum20
@skullkrum20 2 жыл бұрын
@@longshin4299 I really want to keep the readme lean. Everything that is not about basic usage should be only in the documentation website.
@mxkmn
@mxkmn 2 жыл бұрын
Just now tried unsuccessfully to add navigation with this library. It looks like a load of crap. The documentation doesn't work. Samples from github won't run because of wrong configurations. Half of the features are already "deprecated". Wasted 3 hours of my time.
@skullkrum20
@skullkrum20 2 жыл бұрын
Hey @mxkmn ! Are you sure you followed all steps in configuration? Also, samples from the library project GitHub are guaranteed to work always. What GitHub did you get wrong samples from? We have literally zero deprecated features 😅 What we have is some small APIs that were replaced with better versions of themselves. This is how a library evolves without making breaking changes, you know? 🙂 Please hit me up on Twitter DM or open an issue on GitHub with the problems you’re facing. I’d be glad to help 🙂
@deviantstudio
@deviantstudio 2 жыл бұрын
same thoughs when i tried original google navigation. what a waste of time... but this lib looks very promising. probably most well architected, based on what i saw in the docs. so @mxkmn you should reconsider if you chose a profession right ;)
@mxkmn
@mxkmn 2 жыл бұрын
@@deviantstudio I wrote this comment amidst an imminent deadline for those who are also considering this library in order to not have to deal with the complexities of a standard implementation. The problem is that I was able to run everything without additional libraries, while the library from the video didn't work by copying and provided incomprehensible documentation. This library could be a lifesaver for a large project, but in a small project (like my course work) it's not hard to do everything without it. In fact, I would like to try this library again when I need it. I'll be sure to add new thoughts to my comment afterwards. Programming has been my hobby for five years, but I'm new to Android. However, I will definitely consider a career change xd
@bro_chenzox
@bro_chenzox Жыл бұрын
🏅
@Theotoffel1
@Theotoffel1 2 жыл бұрын
03:32 the start ist very interesting
@hamuelagulto796
@hamuelagulto796 2 жыл бұрын
Isn't Google going to fix compose navigation?
@skullkrum20
@skullkrum20 2 жыл бұрын
There is nothing to fix. This is only a matter of usability and its probably somewhat discussable. So, if your question is "are they going to improve usability?", my answer is "I don't think so".
@hamuelagulto796
@hamuelagulto796 2 жыл бұрын
@@skullkrum20 that's unfortunate
@fensom80
@fensom80 2 жыл бұрын
Crispy bacon mmmmmm....
@mariush873
@mariush873 2 жыл бұрын
Library looks cool but, I am not sure if passing a whole parcelable object is the best way. I think what we should do is to pass only userId and then on the next screen use a room database to get user by this specific id. What do you think? :D
@skullkrum20
@skullkrum20 2 жыл бұрын
Definitely for this use case, User is most likely something you want to store somewhere in your database and just pass ids around. But there are situations where that is not very practical and a small Parcelable class is a better way to do it. After all we have always had that possibility, so I just added this support to let developers choose for themselves :) But you don't need to use Parcelable to justify this library. It will make your life much easier and the code much cleaner and safer!
@deviantstudio
@deviantstudio 2 жыл бұрын
oh yes! room database is the most suitable tool for passing few primitives from screen to screen (sarcasm). i think google should deprecate whole lib and start it from scratch. the current one was a mistake.
@hussien_fahmy
@hussien_fahmy 2 жыл бұрын
Actually I didn't like it, yes it's a great work, BUT there is no way to summarize or to see the overview navGraph, no way to specify the routes, any destination can accessed any other destination, in projects with +5 screens it will very hard to maintain that if you passed your navigator everywhere
@skullkrum20
@skullkrum20 2 жыл бұрын
> there is no way to summarize or to see the overview navGraph, You can just open the generated NavGraphs object, its way better to overview your Nav graphs than official compose navigation which you need to always look at all the routes, args, etc. > no way to specify the routes Yes, there is. You can set your route in the annotation. But anyway, the library will mostly abstract you from routes, you most of the times don't even need to think there are routes underneath. > any destination can accessed any other destination Don't know what you mean. In official compose navigation you can also access all screens from all screens, you just need their string routes. If you mean the way we navigate with DestinationsNavigator, you don't need to do it that way. You can still manually call your screens in the DestinationsNavHost last parameter and pass lambdas, just like you would with official compose navigation, except way clearner and type-safer! Would love to talk to you and show you just how great the library is :)
@hussien_fahmy
@hussien_fahmy 2 жыл бұрын
Yes it's a great work, I didn't ignore that sir What I did not like is the way to use the library, when you use the official one you can use the nave Controller in one place So you can see an overview of all the app navigation structure. But with this library, if I have more than like 10 screens I will got lost! I will not able to see which destination navigates to specific destination because the navigator passed to every destination and I have to read all this code, or the generated nav Graph as you mentioned which I think it's not practical. The library is a great, I loved it especially when you develop a small app like 5 screens for example, But it really need to consider this feature, the way of navigator use need to be modified to be more like Google implementation as the nav Controller need to be in one place and not passed to any other composable, to be able to test your navigation logic and to see an overview of all destination however its not also the best overview in my opinion. Thanks for your time replying to me🤗
@skullkrum20
@skullkrum20 2 жыл бұрын
@@hussien_fahmy thank you for your kind words! I feel like you did not read the last part of my reply though 😄 Using a navigator on each screen or not is a choice you make when using Compose Destinations just as it is when you don’t. You can have all navigation logic in the DestinationsNavHost! Just don’t add the navigator in the parameters of the screen and call your screen in the DestinationsNavHost passing normal lambdas. Exactly like official way but much cleaner because you don’t need to deal with nav args and such in the same place. Also exactly why is it not practical to open the NavGraphs file? I cannot understand why 😁 To me its way more practical than having to infer navigation graphs between all the arguments code and such. Especially in complicated projects with tons of screens! You got it wrong, the official library is fine for apps with 5 screens but gets messy with complicated apps if you’re not really careful. With compose destinations its always going to be clean no matter how much screens and nav arguments you have 😉
@skullkrum20
@skullkrum20 2 жыл бұрын
And I haven't even told you the feature that definitely closes this arguments forever: There is support in Compose Destinations to let you still use the normal NavHost, call your screens and all that exactly the same way you do with official library but just way cleaner and type-safe. There are extensions on the NavGraphBuilder that let you pass a generated Destination and that's it, you get on the trailing lambda the nav args in a type-safe way and there is way less boilerplate and unsafe code you have to write :) You can check on the docs (that is in the github repo) and check "Navigation Host Composables" -> "Vanilla NavHosts" section!
@hussien_fahmy
@hussien_fahmy 2 жыл бұрын
Wow that's very very great work, I should apologize for my first words. But really this ability and features should be in the readme file or mention to open the website link to know this usage. I wouldn't know it if I commented here and you replied to me @Rafael Costa you did a great work.. 😃😃
@carbaj03
@carbaj03 2 жыл бұрын
if the parcelable featture isn't provide for the compose navigation library is because is a bad practice. Id's are your friends :)
@kinggeorges625
@kinggeorges625 2 жыл бұрын
I do hate ID's 🤨 which required to make extra API calls. In the past I have used instead the DB to cache data and collect it with the ID
@skullkrum20
@skullkrum20 2 жыл бұрын
And what about passing those ids in a type-safe manner? Is that a bad practice too? :D Btw compose navigation library supports passing Parcelable. It is supported, it just needs extra steps to set it up properly. You can check their docs on Kotlin DSL navigation - custom types section.
@tonnie7079
@tonnie7079 2 жыл бұрын
@@skullkrum20 Wow, you know your stuff man, I am impressed.
@deviantstudio
@deviantstudio 2 жыл бұрын
you know what is a bad practice? tell other people that things they used to is a bad practice. i personally use parcelables as screen args for more than 10 years. and the only 'bad" thing i see here is that requirement of make it Parcelable. other ui frameworks allow you to pass any kind of data, not limited to parcelable/serializable.
@tonnie7079
@tonnie7079 2 жыл бұрын
@Destination(start = true) is deprecated instead use @RootNavGraph(start = true) together with @Destination
@AbdulWaheed-fb3it
@AbdulWaheed-fb3it Жыл бұрын
Super Cool and Super Easy
How to Support All Screen Sizes in Jetpack Compose
11:57
Philipp Lackner
Рет қаралды 28 М.
Should You Use Compose State or StateFlow in Your ViewModels?
13:59
Philipp Lackner
Рет қаралды 74 М.
小宇宙竟然尿裤子!#小丑#家庭#搞笑
00:26
家庭搞笑日记
Рет қаралды 15 МЛН
Full Guide to Delegation in Kotlin  - Android Studio Tutorial
18:10
Philipp Lackner
Рет қаралды 67 М.
How to Write your First Jetpack Compose Test (Step-By-Step)
17:13
Charfaoui Younes
Рет қаралды 2,9 М.
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 110 М.
23 - NAVIGATION - Android Jetpack Compose
19:25
MkrDeveloper
Рет қаралды 10 М.
Compose Navigation Animations (NEW)
17:28
CodingWithMitch
Рет қаралды 26 М.
Navigation Basics in Jetpack Compose
14:40
Stevdza-San
Рет қаралды 64 М.
Full Guide to Nested Navigation Graphs in Jetpack Compose
12:01
Philipp Lackner
Рет қаралды 60 М.