eygraber
12/09/2022, 5:52 AM@Composable
fun ColorPicker(
modifier: Modifier = Modifier
) {
BoxWithConstraints(
modifier = modifier.aspectRatio(1F)
) {
val diameter = constraints.maxWidth
...
}
}
The problem is that it looks like if a user passes a Modifier to ColorPicker with size constraints, it would follow those. However, BoxWithConstraints uses the incoming constraints to size itself, not the constraints in its Modifier.
In a case like this, should I be wrapping BoxWithConstraints in a Box that uses the Modifier parameter, or is it expected that the caller of ColorPicker should wrap it in whatever layout it needs, and set the size constraints appropriately?Zach Klippenstein (he/him) [MOD]
12/09/2022, 10:36 AMeygraber
12/09/2022, 6:28 PMrequiredSize because of a fillMaxSize somewhere higher in the hierarchy. Guess I need to re-read how layout and placement works 😅eygraber
12/09/2022, 7:46 PMSurface(
modifier = Modifier.fillMaxSize() // bigger than 250.dp
) {
Box(
modifier = Modifier.size(250.dp).background(Color.Yellow)
)
}
This results in the Box taking up the full size of the Surface. I have to use requiredSize to get the behavior I expect. But it seems weird to me that the incoming constraints override size.Dan MacNeil
12/10/2022, 3:20 PMZach Klippenstein (he/him) [MOD]
12/11/2022, 12:46 AMeygraber
12/12/2022, 10:59 PMpreferredSize (which is actually what the kdoc calls it).Zach Klippenstein (he/him) [MOD]
12/12/2022, 11:21 PMeygraber
12/12/2022, 11:22 PM