Vinay Gaba
08/08/2023, 3:50 PMcomposed
Modifiers to the new system. I'm wondering if there was a specific reason for holding off on more communication until now?shikasd
08/08/2023, 3:52 PMshikasd
08/08/2023, 3:53 PMVinay Gaba
08/08/2023, 4:01 PMcomposed
Modifiers. This sounds like something that requires low effort but should have high ROI. Android Dev Rel superheroes, help your boy out πshikasd
08/08/2023, 4:21 PMVinay Gaba
08/08/2023, 4:22 PMColton Idle
08/08/2023, 5:43 PMwe have a ton ofjust out of curiosity. what are those? 2 years of compose and i dont think ive used the composed modifier. lol πModifierscomposed
Vinay Gaba
08/08/2023, 5:45 PMCompositionLocal
. We could've probably passed the value into the function but wanted to simplify the usage.shikasd
08/08/2023, 6:00 PMPaddingElement
or SizeElement
. we also have samples for CompositionLocal
.Vinay Gaba
08/08/2023, 6:02 PMshikasd
08/08/2023, 6:02 PMBen Trengrove [G]
08/08/2023, 11:00 PMVinay Gaba
08/08/2023, 11:01 PMBen Trengrove [G]
08/08/2023, 11:05 PMCompositionLocal
. We could've probably passed the value into the function but wanted to simplify the usage."
This is the exact question we are still debating over actually. The most correct/performant option is to use CompositionLocalConsumerModifierNode
but feedback is that feels like overkill just to reference a theme value so we want to get the recommendation right
Sample of that: https://cs.android.com/androidx/platform/tools/dokka-devsite-plugin/+/master:testData/compose/samples/ui/samples/ModifierCompositionLocalSample.ktAlbert Chang
08/09/2023, 12:33 AMMaterialTheme
doesn't expose any `CompositionLocal`s directly so I don't think it's even possible to read a theme value from modifier node now.Vinay Gaba
08/09/2023, 2:30 PMThe most correct/performant option is to useOn seeing the example, it does look like it's fairly involved. I had seen Leland's talk last year so don't remember all the details but does it also cover this use case? Do you remember on the top of your head?but feedback is that feels like overkill just to reference a theme value so we want to get the recommendation rightCompositionLocalConsumerModifierNode
shikasd
08/09/2023, 2:46 PMshikasd
08/09/2023, 2:50 PMfun Modifier.themedBackground() = composed {
Modifier.background(MyTheme.current.backgroundColor)
}