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

Ian Warwick

01/31/2020, 11:30 PM
Is there a modifier that does something like
WRAP_CONTENT
?
a

Adam Powell

01/31/2020, 11:37 PM
That's generally the default behavior, what are you trying to do more specifically?
compose layouts measure based on constraints provided by the parent that contain min/max for width/height
there's a
LayoutWidth.Fill
(and matching for
Height
and
Size
to set min = max for those constraints and continue measurement, but most layouts try to size conservatively by default for a very
WRAP_CONTENT
-like behavior
i

Ian Warwick

02/01/2020, 12:02 AM
nice thanks @Adam Powell seems I was applying
Modifer.None
to a
Card
inside a popup and it was then applying more space. By removing the modifer override of
Modifer.None
it wraps the items nicely, screenie with modifier:
commented out modifier
a

Adam Powell

02/01/2020, 12:06 AM
Modifier.None
is just an empty sentinel, it's used as the default parameter value for modifiers everywhere. I'm willing to bet something else was at play there...
What was the code calling this passing as the modifier?
What's the
Container
around the
Card
there for?
generally when you accept a modifier you want to pass it to the root of the subtree that your composable is emitting
i

Ian Warwick

02/01/2020, 12:16 AM
yes sorry you are right there is much more going on here caller passing in modifiers, I probably put the container there without thinking about wether it was correct! 🙂 will check it through thanks! :)
a

Adam Powell

02/01/2020, 12:18 AM
at least it was easy to track down where the weird behavior was coming from!
I think all of the stock modifiers should have pretty legible/useful `toString`s so just
println
it or take a look at one in the debugger at a breakpoint and you should be able to see what's up pretty quickly
👍 1
once we get this integrated with the layout inspector there should be a nice visual display of such things
👍 1
i

Ian Warwick

02/01/2020, 12:24 AM
yeh! for some reason I explicitly added a
LayoutHeight.Constrain
to fix something else and forgot about it 😆 anyway wow its gone midnight and super tired better leave this till morning thanks for all the super work! Its very awesome to work with very happy where its going and nice one about the string info 👍
☺️ 1
💯 1
2 Views