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

louiscad

07/29/2020, 5:39 PM
Isn't
Modifier
the new
LayoutParams
in a way?
v

Vinay Gaba

07/29/2020, 5:42 PM
I think Modifiers do a lot more than just that.
☝️ 2
2
z

Zach Klippenstein (he/him) [MOD]

07/29/2020, 5:43 PM
Kinda, yea. It's not an exact 1:1 relationship, but it is one of their use cases.
a

Adam Powell

07/29/2020, 5:44 PM
Kind of a fusion of LayoutParams and the assortment of general-purpose properties that accumulated on the
View
class over the years, but with (ideally) less of a fragile base class problem
l

louiscad

07/29/2020, 5:46 PM
@Adam Powell You mean more… composable?
r

romainguy

07/29/2020, 5:47 PM
It’s so much more 😛
To me modifiers are closer to the concept of components in Entity-Component Systems
2
🤔 1
a

Adam Powell

07/29/2020, 5:51 PM
@louiscad yes, the strong ordering property is a big part of what creates that composability and why I think it's worth the tradeoff of explaining why we don't have a fixed ordering of position-independent margin/padding 🙂
l

louiscad

07/29/2020, 5:52 PM
It’s so much more 😛
So much or too much? Regardless, I'm wondering about the discoverability of these abilities (at least, the built-in ones). (I'm waiting for the next dev version that will work on Kotlin 1.4-rc to start playing with compose dev serioulsy, I'll probably see myself, event though it may change in subsequent releases)
v

Vinay Gaba

07/29/2020, 5:52 PM
The mental model I’ve been using is that they are “component decorators”. Any time I want to add more UI functionality(gestures, appearance, etc) to a composable, I either look for an existing Modifier or try to think about how a custom modifier might be useful. And I rarely ever need custom modifiers for now 😛
👍 2
👆 1
r

romainguy

07/29/2020, 5:52 PM
I don’t think discoverability is any worse than with regular composable functions. It might actually be better thanks to the code completion context provided by chaining modifiers
👍 3
How we present them in the docs is a different problem though
👍 1
2