https://kotlinlang.org logo
#compose
Title
# compose
b

Ben Trengrove [G]

11/22/2023, 9:18 PM
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

vide

11/22/2023, 9:29 PM
Oh wow, nice! I will read through these to see if there's something I have missed so far
e

eygraber

11/22/2023, 11:15 PM
@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

Ben Trengrove [G]

11/22/2023, 11:22 PM
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

eygraber

11/22/2023, 11:25 PM
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

Ben Trengrove [G]

11/22/2023, 11:26 PM
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

Stylianos Gakis

11/23/2023, 12:43 AM
The relevant thread btw that Ben mentions here for anyone interested 😊 https://nitter.net/GakisStylianos/status/1727461762578968605?t=WdUXbupRwj49gf4P-MoGzw&s=19
b

Ben Trengrove [G]

11/23/2023, 3:56 AM
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

eygraber

11/23/2023, 4:48 AM
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

ascii

11/23/2023, 4:58 AM
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

Ben Trengrove [G]

11/23/2023, 5:20 AM
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

PHondogo

11/23/2023, 4:15 PM
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?
4 Views