Type-Safe Navigation with the OFFICIAL Compose Navigation Library

  Рет қаралды 58,807

Philipp Lackner

Philipp Lackner

Күн бұрын

In this video I'll show you the Type-Safe Navigation with the OFFICIAL Compose Navigation Library!
💻 Let me be your mentor and become an industry-ready Android developer in 10 weeks:
pl-coding.com/...
⭐ Courses with real-life practices
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/...
Get my FREE PDF about 20 things you should never do in Jetpack Compose:
pl-coding.com/...
Regular programming advice on my Instagram page: / _philipplackner_
Join my Discord server:
/ discord
Get the source code for this video on GitHub:
github.com/phi...

Пікірлер: 253
@sosaucemp3
@sosaucemp3 4 ай бұрын
7:17 He sounds so happy about it 😭
@WakeupDev.
@WakeupDev. 4 ай бұрын
yea... I felt that in his voice 😄
@farfar5828
@farfar5828 4 ай бұрын
😂😂 I felt that too
@KevinMeneses
@KevinMeneses 4 ай бұрын
X3
@BSS_00
@BSS_00 4 ай бұрын
its like every developer after a new good feature
@ilyastoletov
@ilyastoletov 3 ай бұрын
Cause this feature reduces hundreds of lines of boilerplate parsing arguments, ensuring they're not null, etc...
@Shengdanya
@Shengdanya 4 ай бұрын
Yes. Yes. Yes. Omg. Tears of joy. Really needed a new way!!!!!
@ayitinya
@ayitinya 4 ай бұрын
This is actually the best news in android i've heard in a really long while
@annaberkovitch85
@annaberkovitch85 4 ай бұрын
Philipp, I've no words!!!! Thank you for brightening my day! But mostly thank you for the truly TREMENDOUS amount of work you're doing to bring all those updates to us in a manner that's both timely and incredibly clear. Just... Thank you!!!!
@PhilippLackner
@PhilippLackner 4 ай бұрын
🙌❤️
@nanonkay5669
@nanonkay5669 3 ай бұрын
2 reasons why I started and stopped Android dev within a year: 1. Lack of a package manager that handles all package installations, they're dependencies and versions without having to manually do it every time and manually tweaking package and dependency versions 2. Navigation between screens The second one seems to be solved. If the first one gets solved, I'd be back to Android dev in a heartbeat
@lindaporsius
@lindaporsius 4 ай бұрын
Could you please make a video about Drawer/BottomNav using this lib? Especially how you would handle the selected-property of a nav-item (and the corresponding icons)
@JackCheungShingKit
@JackCheungShingKit 4 ай бұрын
That JSON serialization is how I did before for passing argument. Though my approach on serialization & deserialization boilerplate can be ugly. Agree that it is a great improvement. I wish they made this available since the beginning.
@Jessewb786
@Jessewb786 4 ай бұрын
I was using Circuit and it's own navigation, so I've been making use of type-safe screens with painless parcelable arguments for quite a while. It's nice to now see this present in the official library.
@magedahmed5981
@magedahmed5981 4 ай бұрын
Finally .. a simple straight routing .. 😊
@amit470
@amit470 4 ай бұрын
Such a relief, I need this to be in compose stable
@ilyastoletov
@ilyastoletov 4 ай бұрын
Just use Reimagined Navigation that has a bunch of cool features such as type-safe navigaiton and Parcelable support out of the box. Also community have the Decompose as a multiplatform solution. Both of these libraries are completely driven by community so if you prefer only official libraries it's always OK
@vit4mint685
@vit4mint685 4 ай бұрын
Just wrapped up a project that used a lot of the old compose navigation. Looking forward to this
@worthex_2
@worthex_2 4 ай бұрын
Omg this feels much more satisfying to do nagivation straight with classes now. Beautiful update.
@MatthewSmith-mt3kz
@MatthewSmith-mt3kz 4 ай бұрын
The demo is a pretty simplistic, but a good intro into the new Nav feature. In the real world you'd be getting the screen argument from savedstatehandle. Keep up the good work Phillipp, your videos have saved me hours. Thank you.
@rishabhsaraswat1928
@rishabhsaraswat1928 4 ай бұрын
4:03 we can clearly see his happiness.
@raeesmohit01
@raeesmohit01 4 ай бұрын
It was really a big problem for beginners for me to change the screen and you made it easy now
@geanbrandao4987
@geanbrandao4987 4 ай бұрын
It's so easy now. Thank you for bringing this content to us! Keep up the great work, hugs from Brazil.
@supadeurali9848
@supadeurali9848 4 ай бұрын
Wow wow wow.... tears in my eyes as well. So excited to try this.
@coalacorey
@coalacorey 4 ай бұрын
Finally! As soon as the stable release is out I will implement it.
@Zscor27
@Zscor27 2 ай бұрын
Thanks for keeping us updated on new stuff. The eco system changes so fast in Android, and there really isn't many youtubers keeping up but atleast we have you :D
@moheltanani1036
@moheltanani1036 3 ай бұрын
If you were in tears, I'm crying right now hehe. Love it, thanks a lot!
@Mexicanerie
@Mexicanerie 4 ай бұрын
Amazing ! I'm already making a PR on my projec with theses improvments 😁
@vengateshm2122
@vengateshm2122 4 ай бұрын
There was a crash when we try to pass custom type like User(val id: Int, val name:String, val isPremium) in 2.8.0-alpha08 version which is fixed recently in version 2.8.0-beta01.
@douglascf2
@douglascf2 4 ай бұрын
Thanks for the video! So exciting! I have a question, does it automatically work with SavedStateHandle in a ViewModel?
@jeonie9682
@jeonie9682 4 ай бұрын
I did today and worked well. but you should use the method now like "SavedStateHandle.toRoute" not just "savedStateHandle" in a ViewModel.
@siftoshka
@siftoshka 4 ай бұрын
What if I need this parameters on ViewModel?
@TheRobertJamison
@TheRobertJamison 2 ай бұрын
Even more relevant as of July 3rd, since JetBrains released version 2.8.0-alpha08 of their KMP compatible version of navigation-compose.
@yahussainmazloom1
@yahussainmazloom1 4 ай бұрын
Finally some good updates, finally so much relief after this update
@MateuszKowol-nu8lr
@MateuszKowol-nu8lr 4 ай бұрын
Still nice improvement however the main advantage of f.e. voyager is that you do not need to declare the navHost and its all routes. Voyager allows you to just jump from ScreenA to ScreenB without declaring it in your navHost. Google's navigation is still kinda similar to the fragment navgraph but without the childlish arrowing thing.
@ASTAppLab
@ASTAppLab 4 ай бұрын
being as Android Native Developer appreciate 👍 you
@quangthaita6084
@quangthaita6084 4 ай бұрын
Thanks who created this, thanks Phillips ❤ That's what we're waiting for
@okeziokezino
@okeziokezino 4 ай бұрын
Philip my guy, this is awesome... love all your work
@aiyuayaan
@aiyuayaan 4 ай бұрын
Thanks @Philipp Lackner, one thing I have to mention is we can't send empty string as value, I am using 2.8.0-beta01.
@SunAndMoon-zc9vd
@SunAndMoon-zc9vd 4 ай бұрын
With "empty string" do you mean: 1.a text with no characters; like "" 2. or do you mean undefined 3. or do you mean null
@aiyuayaan
@aiyuayaan 4 ай бұрын
@@SunAndMoon-zc9vd I mean "" this
@9Blurke9
@9Blurke9 4 ай бұрын
Now we need another navigation video to compare all the options with pros and cons for each 😄
@TimKaragosian
@TimKaragosian 4 ай бұрын
This looks similar, but even better than Decompose. As always, thanks for sharing these great videos and quality content!
@paulklein649
@paulklein649 4 ай бұрын
do somebody still wish to work for google and develop shitty frameworks and libs and maybe correct them 2 years later to be somewhat usable? I have the feeling that every dev-product google provides is garbage if jetbrains is not involved in the development
@BigCarso
@BigCarso 2 ай бұрын
What about Compose? Probably the best UI framework in existence
@paulklein649
@paulklein649 2 ай бұрын
@@BigCarso yeah. You mean jetbrains compose just relabeled for android
@BigCarso
@BigCarso Ай бұрын
@@paulklein649 ok you have no idea what you're talking about. Compose was developed by Google team, not Jetbrains
@stijndcl
@stijndcl 28 күн бұрын
​@@paulklein649 ? JetBrains made compose multiplatform years after the android version, and most of it is a 1:1 port of jetpack compose. Not sure what you're on about with that.
@joatancarlos2704
@joatancarlos2704 4 ай бұрын
Thank you for bringing this content in a very didactic way
@tmjromao
@tmjromao 4 ай бұрын
Thanks for the video. Is the bottom navigation also changing accordingly? What is needed to have screenB with bottom navigation graphs? Thanks.
@manticomar1146
@manticomar1146 4 ай бұрын
The questino is in my view model how would I use savedStateHandle to extract the parameters?
@AntliaRodriguez-d9t
@AntliaRodriguez-d9t 2 ай бұрын
Uff faltan tutoriales asi en español, gracias a youtube por los subtítulos! Estaba buscando entender esto y solo con tu video pude
@СергейБобошко-в2л
@СергейБобошко-в2л Ай бұрын
The strings arguments i could pass and old style way... The interesting example will be pass a data class. Somehow somewhen i'll try.
@filipmanevski9872
@filipmanevski9872 4 ай бұрын
Can you make a video on how to implement this way of navigation, using a navigation drawer for example or a bottom nav bar?
@wilkq1110
@wilkq1110 Ай бұрын
hi Philipp, is nice video, Could you please tell us if this new approach to navigation works well as well with bottom bar navigation ?
@bierdav
@bierdav Ай бұрын
I would be the happiest developer in compose multiplatform land, if you make a video about "scalable" Type-Safe Navigation with best practises 😊 I find it hard to structure my compose multiplatform app, because somewhere I always have to mention all the navigation routes, but what if i have 40 of them? I can't image of way that isn't completely messy with this huge amount of screens
@youNeverThoughtAboutIt
@youNeverThoughtAboutIt 3 ай бұрын
Shouldn't we store those composables for different screens in separate files? Maybe I'm just thinking in old Fragment style though
@meidy3795
@meidy3795 4 ай бұрын
Good information Phillip ! Thos wpuld really helped my ptoject for compose multiplatform
@MO1NKHAN
@MO1NKHAN 4 ай бұрын
OMG, I wish this could have come earlier. In my first app I have spent so much time and effort just to handle navigation without relying on 3rd party libraries. I have an e-commerce app running in production with lots of screens hanging on those route strings. It's time to refactor and remove all that boilerplate code.
@MonichGPT
@MonichGPT 4 ай бұрын
Where is type-safe bottom sheet navigation? I don't see it in the docs. So for now we can't use type-safe navigation at all?
@normno
@normno 4 ай бұрын
Так забавно наблюдать, как мои любимые yoytebers выпускают обзоры на новые функции библиотек android и kmp примерно в одно и тоже время и у каждого свое красивое решение использования.
@samuelwakoli
@samuelwakoli 4 ай бұрын
Is Kotlin Multi-Platform industry ready? Can I migrate my Flutter project to KMP?
@oneclickmobiledevelopers7825
@oneclickmobiledevelopers7825 3 ай бұрын
Which theme you are using in the android studio, It's awsome..!
@LEEJIHUN
@LEEJIHUN 4 ай бұрын
I was wondering how to migrate the code when using it with BottomNavigation or NestedNavigation
@planet3a
@planet3a 4 ай бұрын
I once said XML way of navigating was better than Compose. Now it's getting better. 😀
@kfirossmatityahu4295
@kfirossmatityahu4295 3 ай бұрын
So actually they got the motivation from Voyager!? (pushing classes as "screens") great!
@darknjko
@darknjko 4 ай бұрын
Thanks again for that demo. Spot on, as always 👍 Originaly, it seemed that the routing library was made to handle all routes as deeplinks. I wonder how deeplinks will work with that new approach? Should we write a deeplink handler that would reroute the user to the proper screen? 🤔
@loklok2003
@loklok2003 3 ай бұрын
But how can I check the currentDestination using Type-Safe Navigation? For example, I would like to check the selected item in the BottomNavigation which was previously done using a string. However, with Type-Safe Navigation, I'm unable to cast NavDestination to a Serializable object.
@AKnght
@AKnght Ай бұрын
Is this out for Compose Multiplatform yet? Great video!
@PratikSahu18
@PratikSahu18 4 ай бұрын
Will the object be injected to viewmodel like it used to inject with the parameters when using hilt?
@BorisJakubov
@BorisJakubov 4 ай бұрын
private val ScreenA = savedStateHandle.toRoute()
@MultiDeivas
@MultiDeivas 3 ай бұрын
It seems like the NavHost causes memory leaks on configuration changes, lovely :)
@chaitanyapenjuri
@chaitanyapenjuri Ай бұрын
How can we navigate to pop backstack from screenB to screenA with some arguments, please explain
@danielreinhold8475
@danielreinhold8475 3 ай бұрын
Looks pretty nice, but in my opinion compose destinations by raamcosta is still easier to use & maintain.
@ordnavile
@ordnavile 4 ай бұрын
Very good, my project is in its final stages. I'm going to take advantage and refactor it to be cleaner. Thank you very much friend.
@Revitalish
@Revitalish 3 ай бұрын
i'm trying so hard to understand where was the problem in passing arguments to screens till now? i mean I haven't tried passing anything except for the ViewModel instance. was that wrong? and if so, then how do I share same ViewModel instance with multiple screens (including nested navGraph)?
@slyene6202
@slyene6202 11 күн бұрын
Please, if you have such code, let us see how to create custom nullable arguments (NavType's)!
@siddharthshakya09
@siddharthshakya09 2 ай бұрын
I have deployed 2 production apps which are used by Big Enterprises. I have used voyager and it's seamless till now. Is it worth moving to official library?
@lazydeveloper7753
@lazydeveloper7753 4 ай бұрын
How do I navigate between two graps containing two screens each usi g type safety? Im confused. Please make a video on this.
@BugraKaraahmetoglu
@BugraKaraahmetoglu 4 ай бұрын
Could you please explain how we can safely integrate vertex AI into the application with Google Cloud Console. I need this urgently.
@cfa532
@cfa532 28 күн бұрын
I am using ver rc01 and met a strange problem when passing two arguments in a data class object. The 2nd argument sticks the value of its first time usage, never changes in the afterward calls. I have to use the old way to get around this.
@Dizzyslizzy
@Dizzyslizzy 24 күн бұрын
I used a json + simple kotlin class to get around this. shouldn't need to tho...
@santyas
@santyas 4 ай бұрын
Great Video!!! How do you retrieve args from the destination viewModel directly? If I use savedStateHandle inside viewModel still needs to safe the possible null argument using ?: or !!
@portusdelphini
@portusdelphini 3 ай бұрын
In a prospect of front end routing this looks like a hell. Still a question why it's so complicated?
@kurtispalu
@kurtispalu 3 ай бұрын
How do I reference the object into a navigation drawer argument? I keep getting crashes when I try to use a var to carry the object name into the navigation drawer item. Thanks
@EdwinRebolledo
@EdwinRebolledo 3 ай бұрын
We can use it in prod apps ? its on alpha or you recommend to use it from now on
@diabetesatuniversity
@diabetesatuniversity 4 ай бұрын
Thanks this is helpful. Love your videos.
@kuromujou1346
@kuromujou1346 4 ай бұрын
looking forward you make a video about this but with multiple nested graph. im newbie and im so confuse right now.
@krasavec7088
@krasavec7088 Ай бұрын
Is it possible to use that with nested graphs?
@resitsahin7787
@resitsahin7787 4 ай бұрын
Hi Philip, can you make a video about drag and drop of lazy column, i have stuck there. It seems they have recently added this capability.
@MrMacromicro
@MrMacromicro 4 ай бұрын
Thanks philip ,you are really amazing.
@ntikomathaba2662
@ntikomathaba2662 3 ай бұрын
Is this the best navigation for Compose Multiplatform?
@Lucky_PhilB
@Lucky_PhilB 4 ай бұрын
Havent had the chance to play with this yet. How does it deal with deeplinks? And is this implemented for kmp compose?
@Pulkit__7
@Pulkit__7 4 ай бұрын
KotlinX Serialization brings back old memories from 2019
@amirhosseinghafoorian9985
@amirhosseinghafoorian9985 4 ай бұрын
Cool update 🤩 what I'm more curious about is that how does recommendations work ? is it an extension or a live template or smth ?
@PhilippLackner
@PhilippLackner 4 ай бұрын
Gemini AI suggestions in Android Studio Jellyfish
@rifatkhadafy9786
@rifatkhadafy9786 8 күн бұрын
but what will happen if theres multi module, like screen from Module A want to navigate to Module B and with Multiple Different Object the problem i cant import directly Module B to Module A it will cause circular dependency
@PhilippLackner
@PhilippLackner 8 күн бұрын
@@rifatkhadafy9786 navigation setup doesn't belong in any module that's not the app module. For learning this properly, check my essentials bundle: pl-coding.com/android-essentials-bundle
@ronalkspdev
@ronalkspdev Ай бұрын
hay un error en el OnRestart cuando la activity se pausa por poca ram y se ejecuta el onRestar manda error de restoring back stack alguien le paso?
@upbeatsarcastic8217
@upbeatsarcastic8217 4 ай бұрын
This is most exciting Compose feature to date imo. Having just finished a Compose app, navigation was the ugliest thing to deal with by a long way.
@yanneckreiss
@yanneckreiss 4 ай бұрын
Haha I can relate to your joy about this update so much 😂Great video!
@WakeupDev.
@WakeupDev. 4 ай бұрын
Lucky me.. I just started doing compose and KMP, so I haven't suffered like you 😄 I see some cool changes
@JamesShisiah
@JamesShisiah 2 ай бұрын
Haha, me too.
@ryantcb
@ryantcb Ай бұрын
Really appreciate your videos. Moving over from iOS to learn JC and OMG we spoiled with Xcode. All this fluff that has to happen around implementing simple tasks like navigation. Genuinely unless they make working in the Android development more user friendly, I can see new devs just giving up and sticking to iOS. Such a headache. If it wasn't for your videos I wouldn't have made it past "Hello, World(Android)". Thank you
@MrBzik1111
@MrBzik1111 4 ай бұрын
I wonder how other libraries (mentioned in the comments) can get use out of Parcelable. For KMP. I thought It was only android thing
@pablovaldes6022
@pablovaldes6022 4 ай бұрын
Still a lot to improve. Dynamic load of graph in other libraries or modules, without the need to load all them upfront.
@mehdiparsaei1867
@mehdiparsaei1867 Ай бұрын
Thanks! How about this code snippet? @Serializable sealed class Screens { data object Main : Screens() data class Settings(val username: String, val emailAddress: String) : Screens() }
@Ayor88
@Ayor88 4 ай бұрын
I've add it to my project and it works really well but now I'm flooding with logcat message : "updateAcquireFence: Did not find frame." This doesn't crash the app or anything, but it's really annoying.
@Matthew01369
@Matthew01369 3 ай бұрын
Hi there, did you manage to fix it? It's happening to me also
@vsv8161
@vsv8161 3 ай бұрын
Same problem
@gloooooom6229
@gloooooom6229 4 ай бұрын
hi! how would i do it if i have 2 UI sets for 2 usertypes? i have a radiobutton on the signup to identify them. how can i navigate them to the right set of UIs i already have my bottomnav that has 5 screens
@Alchemist10241
@Alchemist10241 4 ай бұрын
with this approach how can we do a shared transition between screens?
@zeroarst
@zeroarst 4 ай бұрын
Is there a way to gradually migrate to this meanwhile still keep the current navigation in xml? Simple the current project has large codebase and too difficult to migrate it in one shot.
@manjodh
@manjodh 4 ай бұрын
I am using this approach with shared element transition. When i am navigating from screen A to B. When entering in Screen B I click back button before transition complete the app is getting crashed.Why it is happening?
@ayitinya
@ayitinya 4 ай бұрын
with this, do you create a separate file called and put in all data classes and objects? what would be a clean way to keep the screens? I have also thought of having a sealed class called Screens and then throwing all screens in there. curious to know what you suggest
@ЕвгенийПавлусенко
@ЕвгенийПавлусенко 3 ай бұрын
I personally replaced sealed class with sealed interface and moved all serialized objects & classes to it
@MrMindfullness
@MrMindfullness 4 ай бұрын
I have purchased Essentials course. Will this be incorporated in the course as well?
@mark-147
@mark-147 4 ай бұрын
Any tips on naming? I already use FooScreen for the actual composable UI.
@뚜릅-i6c
@뚜릅-i6c 4 ай бұрын
Can I use the library normally in kmm? Is it superior to voyager and decompose?
@Guilo583
@Guilo583 4 ай бұрын
thanks for video. Is this new lib support compose Multiplatform ?
@random-videos96
@random-videos96 3 ай бұрын
Nice but how can we achieve this if we are using dependency injection and need these args in a view model?
@PhilippLackner
@PhilippLackner 3 ай бұрын
They're still part of saved state handle
@random-videos96
@random-videos96 3 ай бұрын
@@PhilippLackner yes but only single args as a string. What if we need the whole data class as a param in a view model? I guess assisted injection come to the rescue
The ONLY Correct Way to Load Initial Data In Your Android App?
12:27
Philipp Lackner
Рет қаралды 22 М.
Navigation Compose meet Type Safety
16:50
Android Developers
Рет қаралды 11 М.
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 67 МЛН
Expected Ending?
00:45
ISSEI / いっせい
Рет қаралды 11 МЛН
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 59 МЛН
Performance Optimization with @Stable and @Immutable in Jetpack Compose
16:47
This Is My FAVORITE Error Handling Class
28:57
Philipp Lackner
Рет қаралды 30 М.
I am done with ViewModels...
11:15
Sebastian Sellmair
Рет қаралды 3,6 М.
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 43 М.
Let's Fix The Fatal Flaw in TypeScript's Union Types!
13:45
Typed Rocks
Рет қаралды 20 М.
Full Guide to Nested Navigation Graphs in Jetpack Compose
12:01
Philipp Lackner
Рет қаралды 64 М.
Coding Was HARD Until I Learned These 5 Things...
8:34
Elsa Scola
Рет қаралды 453 М.
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 67 МЛН