Stylianos Gakis
04/09/2024, 3:32 PM@Composable
fun Foo(
modifier: Modifier = Modifier,
content: @Composable BoxScope.() -> Unit,
) {
Layout(content = { Box { content() }, modifier = modifier) { measurables, constraints ->
val placeable = measurables.first().measure(constraints)
layout(placeable.width, placeable.height) {}
}
}
How would you name this Layout function? 👀Youssef Shoaib [MOD]
04/09/2024, 4:38 PMPlainCanvas
Youssef Shoaib [MOD]
04/09/2024, 4:40 PMGraffiti
to suggest that the content is being drawn-over.Stylianos Gakis
04/09/2024, 4:42 PMCanvas
I’d 100% suspect to get a DrawScope
somewhere, which is not the case here for sureStylianos Gakis
04/09/2024, 4:42 PMRuckus
04/09/2024, 5:01 PMEarmark
or Allocate
?Ruckus
04/09/2024, 5:02 PMSetAside
Stylianos Gakis
04/09/2024, 5:06 PMAllocate(
modifier = Modifier.Color.Gray
content = { Text("Text here") }
)
What would you expect to see on the screen?
Without having any of the context of this conversation or the impl details of it?
Or
Earmark(
modifier = Modifier.Color.Gray
content = { Text("Text here") }
)
Or
SetAside(
modifier = Modifier.Color.Gray
content = { Text("Text here") }
)
Or
PlainCanvas(
modifier = Modifier.Color.Gray
content = { Text("Text here") }
)
For me none of those describe what happens.Ruckus
04/09/2024, 5:47 PMAllocateSpace
, SetAsideArea
, EarmarkRegion
, etc.), not just the word on its own.Ruckus
04/09/2024, 5:50 PMConsumeMeasuredCanvasSpaceButDontActuallyDrawContent(...)
🙂Stylianos Gakis
04/09/2024, 5:59 PMConsumeMeasuredCanvasSpaceButDontActuallyDrawContentWhy Canvas here?
Ruckus
04/09/2024, 6:03 PMRuckus
04/09/2024, 6:07 PMStylianos Gakis
04/09/2024, 6:09 PMLayoutWithoutPlacement
for now, which is short and starts with “Layout” which might make it a bit more discoverable. And I’ll consider renaming it after more feedback 😄Ruckus
04/09/2024, 6:13 PMStylianos Gakis
04/09/2024, 6:17 PMLayouts
to reach for anything named Layout
by accident.
And if they are familiar with it, seeing the empty placement block layout(placeable.width, placeable.height) {}
should hopefully be enough of a hint of what’s happening. Along with the documentation of courselouiscad
04/11/2024, 8:06 AMFoo
function is not using the size and therefore seems useless. I'm confused.Stylianos Gakis
04/11/2024, 8:11 AMlayout(placeable.width, placeable.height)
does indeed take up the space of the content
, it just draws nothing in that space since I never place it.
Then whatever may be put on modifier
like .background(Color.)
will be drawn on exactly that size that content
would’ve taken.
Run it locally, give it a spin and you’ll see.louiscad
04/11/2024, 8:12 AMStylianos Gakis
04/11/2024, 8:12 AMlouiscad
04/11/2024, 8:12 AMWithSizeOf
would be my name for this functionlouiscad
04/11/2024, 8:13 AMlouiscad
04/11/2024, 8:13 AMStylianos Gakis
04/11/2024, 8:15 AMlouiscad
04/11/2024, 8:17 AMInvisible(…) { … }
?louiscad
04/11/2024, 8:19 AMStylianos Gakis
04/11/2024, 8:21 AMlouiscad
04/11/2024, 8:25 AMYang
04/12/2024, 1:47 PMbut I wanted a composable for size, and then another composable for drawing
DrawingBound
?