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

Jamie Craane

10/09/2020, 2:54 PM
Regarding this change: https://android-review.googlesource.com/c/platform/frameworks/support/+/1435797 is there a specific reason to let the drawing order affect the zOrder instead of an expliciet (and optional) zIndex parameter to the place* methods? When code in a custom layout is re-ordered (for whatever reason) this potentially breaks the layout. Or am I missing something here?
a

Adam Powell

10/09/2020, 2:58 PM
Funny you should ask, your questions mirror an ongoing discussion about exactly that 🙂
Placement order as a baseline is something we think is a good default but allowing explicit ordering as part of the place call is also under discussion
j

Jamie Craane

10/09/2020, 3:02 PM
Ok, thanks for the update. zIndex as a parameter seems like a good addition if one wants to be explicit about the zIndex when adding composables.
1
z

Zach Klippenstein (he/him) [MOD]

10/09/2020, 4:33 PM
When code in a custom layout is re-ordered (for whatever reason) this potentially breaks the layout.
This seems like a good thing to me, generally. It's intuitive that composables' z order is related to their order in code, since most view systems work this way. If you have a custom layout that depends on the ordering of composables and the directly children of that layout aren't an implementation detail of the layout itself, that would be brittle regardless of how z-order is determined, and probably using custom modifiers that set parent data is both a more readable and more robust way to identify children to the layout.
a

Adam Powell

10/09/2020, 6:52 PM
Yeah we're thinking of a few different potential angles; the current system, one where Layout Modifiers could augment the Z coordinate just like
Modifier.offset
does, or one where it's expressed as parent data and is only available from layouts that choose to support it
The first two have the advantages of universal availability, the third has the advantage that a consumer can't break the layout contract with a misplaced modifier
(since the final decision on ordering would be determined by the parent layout, which could enforce guarantees)