If you found things in this video a bit off, in particular, the explanation for the default, I think that might be because some of the explanation were wrong (imho): 1. @6:26 Once you have this: val LocalSpacing = compositionLocalOf( defaultFactory = { Spacing() //Notice this line here. We define a default value for the LocalSpacing. } ) You don't necessarily need the lines: // CompositionLocalProvider( // LocalSpacing provides Spacing() // ) { // // } The last lines enable you to update the value for LocalSpacing or to set it in case one was not set already, but, in this video we already set a default value when we define the CompositionLocal. 2. @9:54 The 2nd explanation as to why not to use LocalComposition - I think he got the documentation wrong. In the documentation when they say that you better have a default value, I think what they mean is this: val LocalSpacing = compositionLocalOf( defaultFactory = { Spacing() /*Notice this line here. We define a default value for the LocalSpacing. Better have some value here, as opposed to throw an exception. */ } ) If you don't have a value here, you need to throw an exception in the default factory. Then, whenever some composable calls LocalSpacing.current, developer needs to make sure that some upper composable does indeed set the value for LocalSpacing via "CompositionLocalProvider(LocalSpacing provides x) { ... }". From the documentation: "... Not providing a default value can cause problems and frustration when creating tests or previewing a composable that uses that CompositionLocal will always require it to be explicitly provided."
@utkubilgin2818 Жыл бұрын
hello, can you share the document?
@ajailani43 жыл бұрын
This is so cool. I've never known about this customization before until I found this video. Keep on it!
@PhilippLackner3 жыл бұрын
Glad you like it!
@ramasubramanian31543 жыл бұрын
Hey Philip. It would be cool if you can a video series going through some open source git projects and explaining the project structure. How the data flow works and all that stuff
@jatinvashisht42933 жыл бұрын
This is excellent, now I will make such LoacalCompositions for many other values also. Thanks Philipp
@GakisStylianos3 жыл бұрын
Be super wary about what you're using it for. It's very easy to abuse it and regret it later
@simonsloooow3 жыл бұрын
This is very useful for novices in Compose like me! Thanks Philipp~😘
@jeckonly58533 жыл бұрын
Yeah!! I learned a lot from this video!!
@ubersticks3 жыл бұрын
Boom! Another great lesson. Thanks, Philipp!
@PhilippLackner3 жыл бұрын
Thanks you're welcome!
@_Mr_Megh_ Жыл бұрын
👉👉Good Morning sir I am from India and whenever I see your video I inspire and wants to become Like you and thanks you are not less than celebrity for us . keep doing ill always support .👈👈
@davidozersky412 Жыл бұрын
@7:09. I would like to variations within a theme, for example Button Large, Button Small, Button Expressibve etc. Can you create sub-themes? Also what about custom values that could be used within the context of a more complex composable? Lets say you have a composable built from a textview, a background and a button. Can you match elements with the themes? For example lets say you have a spacer that's between a text and a button; and it could be narrow, wide or huge, and you want to create one style for each. That would mean you would want to have one style, or one base theme and multiple child themes. Can you set something in the theme like textButtonSpacing and then apply it in the composable, while setting in the themes?
@anhlongnghien3 жыл бұрын
Hi philipp, can you enable subtitle/cc for this video? sorry for my bad english!
@thegreatwarrior49893 жыл бұрын
Your content is always special and unique 👍👍👍👍👍👍👍👍👍👍👍👍👍👍
@alij3fer3 жыл бұрын
Brother as usual you are creative and distinctive 💯
@PhilippLackner3 жыл бұрын
Thank you so much 😀
@OmarMagdy404 Жыл бұрын
Wow! Composition Locals = Redux in React and React Native. Thanks a lot bro. 😁 😁 Your videos are awesome. I am watching your videos 24/7 Keep it up. 👍
@marlonlom Жыл бұрын
00:05:13 ... the same approach applies to tablet and foldables?
@yehiaahmed70473 жыл бұрын
Super great video as well . I really love such way to provide my themes
@mustafaammar5513 жыл бұрын
Very cool video thank you bro
@alonshlider48812 жыл бұрын
9:15 What about a multi module app? Will creating a MaterialTheme file for each module be a good solution?
@jasalvador3 жыл бұрын
Thanks a lot! Great tip.
@Guilo5833 жыл бұрын
Thx for the tips
@khalidmohammed78203 жыл бұрын
Its amazing and very useful, thank you very much
@dmytromarchuk30233 жыл бұрын
I just wonder why Spacing is not a part of Material Design concept yet
@KotlinBek2 жыл бұрын
Hey Philip, Great tutorial as usual I want to add my custom colors and I also want them change in dark mode. How can I achieve that? here you showed spacing which doesn't requires modifications in light/dark mode. thanks in advance! :)
@kingcoder76543 жыл бұрын
❤️❤️
@ubersticks Жыл бұрын
Is it bad practice to include the top-level Surface inside the ComposeCustomThemingTheme()? It isn't clear or consistent when to use a top level Surface. MainActivity frequently includes this, but not always. Also in Compose previews you need to wrap your call with ComposeCustomThemingTheme { } but not normally use a Surface() {} too.
@nakeepanpi93493 жыл бұрын
This is amazing video. So I want you to make video with work manager and android key chain if you could. thank you.
@dreamerslab2 жыл бұрын
Super Cool 👏
@sayyid54166 ай бұрын
why don't directly use these values from data class like: Spacing().medium ?
@jacobgonzalez47462 жыл бұрын
Awesome 🚀
@yiyoascen2 жыл бұрын
how do you test for composables properties like background color and style?
@sooshil2 жыл бұрын
In XML, we put our own custom named colors in both light and night colors.xml file with the same color name. And we call that color from code. Light and Dark colors are automatically handled. How can we achieve that in compose? I only see predefined color sets like.. primary, onPrimary etc. but how can we add our own.. myOwnColor and define two values for light and dark theme? Do we always need to call isSystemInDarkTheme and assign two different colors from every composable?
@7xFuryPlayz Жыл бұрын
sir you can change it according to your needs, but first you should know that which pre-defined color names represnts which surface or you can say (compose) in the app , like , primary represents the topbar color , , onprimary represents the color of things present on the topbar, like options menu , title of your app r screen on topbar , and if you might wonder how would you know that , which color represents which ,surface then jst open the default implementation of the compose you are using , and you can see that which default , style or color that compose uses , so just change your style or color for that specific pre-defined color or style in the theme,
@ashwithchandra26222 жыл бұрын
Bro can you tell me how to extend the scaffold body above and below because it is covering only some part its not covering navigation buttons and also notification bar in OS
@chetangarg96423 жыл бұрын
Hi @Phillipp great content !, you have initialized Spacing two times, 1st in local composition and 2nd time in values of CompositionLocalProvider, You will have two different instances. isnt this a bug?
@JamesBond-mq7pd2 жыл бұрын
Thank U
@vahidgarousi50643 жыл бұрын
so cool 😍
@shivamsethi38293 жыл бұрын
Amazing how similar it is to react context
@aryanvikash19672 жыл бұрын
How can we use a linear gradient color In theme
@Joe-yu9wc3 жыл бұрын
do you have higher level course about compose in clean architecture.
@PhilippLackner3 жыл бұрын
Will come out towards the end of this month 👌
@DeceptiveRealities Жыл бұрын
I am not sure of why this is an advantage over just providing the values as constants. Spacing is just values that don't change, unlike colours which can be themed. You don't theme spacing.
@heavenlife56193 жыл бұрын
*U look like Henry Cevil* 😬
@PhilippLackner3 жыл бұрын
How often do you want to comment this😂
@tessanix9771 Жыл бұрын
how much do you lift at gym?
@TomartStudios2 ай бұрын
bro wtf
@tessanix97712 ай бұрын
Huh
@VietAndroidDevelopers3 жыл бұрын
It is brilliant tips but I don't think different Spacing class for tablet is a good solution. I will come out with my idea that is inherit your video.
@jaspervisser181 Жыл бұрын
why not just create static values? you didn't explained anything
@sanjshe0m3 жыл бұрын
Somehow I hoped that he would do 69.dp for extraLarge...