A quick note to answer a common question I see her...
# compose
b
A quick note to answer a common question I see here. We now have docs released for
Modifier.Node
and migrating away from
Modifier.composed
๐ŸŽ‰ https://developer.android.com/jetpack/compose/custom-modifiers
gratitude thank you 14
๐Ÿ™ 8
๐Ÿ™๐Ÿฝ 1
๐ŸŽ‰ 7
๐Ÿ™๐Ÿพ 2
๐Ÿฆœ 17
Feedback welcome! If you have a question that wasn't answered by these docs, let me know
v
Oh wow, nice! I will read through these to see if there's something I have missed so far
e
@Ben Trengrove [G] in the example give to highlight not breaking the modifier chain, couldn't the
this then Modifier
be left out since
this
is a
Modifier
, i.e.
Copy code
fun Modifier.myBackground(color: Color) = padding(16.dp)
    .clip(RoundedCornerShape(8.dp))
    .background(color)
b
Yeah @Stylianos Gakis just pointed that out on twitter as well. I wanted a simple example to demonstrate this then Modifier
๐Ÿค— 1
Annoyingly, what you wrote still triggers the lint warning so now I have to work out if that is a bug or if something else is going on
e
I figured but the simple version is confusing because it isn't necessary in those cases ๐Ÿฅด Using Hedgehog RC 3 doesn't trigger the lint warning for me.
b
100% agree on the simple case being more confusing if it isn't required
The lint warning is showing for me on iguana, will work it out
s
The relevant thread btw that Ben mentions here for anyone interested ๐Ÿ˜Š https://nitter.net/GakisStylianos/status/1727461762578968605?t=WdUXbupRwj49gf4P-MoGzw&s=19
b
OK no idea why the lint warning is breaking in Iguana but I am updating the page to give that warning further down so that the simple first examples are as simple as possible
e
I think that the crux of the warning about breaking the modifier chain is to make sure you're not using
Modifier
(capital 'M') and that you're using
modifier
or
this
(implicitly or explicitly). The exceptional case should be when you are using
Modifier
in which case you should use
then
a
Yay, was waiting for this! Been wanting to port an animate-on-click modifier over to something like https://developer.android.com/jetpack/compose/custom-modifiers#sharing_state_between_modifiers_using_delegation, but the example uses private classes. Should we expect them to be public in the next release?
b
It might not be making the node public, but we want to have a solution to be able to delegate to existing modifiers or their functionality
and yes Eliezer, I reworded the warning slightly as well. Thanks for the feedback
p
In section example https://developer.android.com/jetpack/compose/custom-modifiers#zero_parameters There is a class FixedPaddingNode. Is there any reason why it is not an object like FixedPaddingElement?