Hi! Probably was already asked, but I'll try and d...
# compose
e
Hi! Probably was already asked, but I'll try and duplicate: why do we need constraint layout in Compose? Isn't Compose layout system able to flatten complex nested hierarchies?
z
Deep nesting is deep nesting – with `View`s, it is expensive because it creates a lot of expensive objects, but also because solving all those constraints recursively is expensive. Presumably the latter issue still affects Compose (still has to measure your composables). Additionally, some complex layouts are just ugly to try to express using simpler layouts. I believe this will also let you use MotionLayout features in Compose, or even animate by swapping `ConstraintSet`s.
1
e
I might be wrong, because I never really had deep dive into layout systems before, but there are layout systems which don't seem to suffer from this problem and solve it natively without additional tools like constraint layout. See Flutter, React, Yoga layout etc.
Also, MotionLayout is useless, fight me
m
Compose should be able to handle deep layout hierarchies efficiently. However, some layouts can be expressed using ConstraintLayout more nicely
s
@Egor Trutenko FYI React is not a layout system, it uses Flex Layout
e
@sngrekov as I said, I'm not really proficient with it. Thanks for clarification on what I meant
@Mihai Popa I'm a little suspicious as to whether implementing constraint layout in Compose is not a waste of time, considering there are a lot of other features to do and constraint, being only quality-of-life feature, might not be as important. Again, not assuming anything, just expressing my own concerns
n
As Mihai said, the main advantage is that there is a class of layouts that are more easily expressed with relative constraints than nested rows and columns (same reason why we had RelativeLayout in android 1.0). The other advantage is supporting MotionLayout -- though you may not care if you think it's useless 😄 (i'd definitely be interested to hear why you think it would be though)
c
There are no tests nor documentation, should we just attempt to construct one? and diddle?
n
You can definitely play with it, but we are still exploring some ideas so so api may change (particularly for MotionLayout)
👍🏻 1