carbaj0
08/11/2021, 5:57 PMColton Idle
08/11/2021, 6:47 PMAdam Powell
08/11/2021, 8:41 PMBox(Modifier.somethingYouDontWant()) {
YourComposable()
}
and you can't do anything about it.Adam Powell
08/11/2021, 8:43 PMModifier.requiredHeight
modifier, which will enforce a given size regardless of parent constraints. The parent will still allocate space with respect to the constraints it gave you, but your composable will stubbornly take on its required size anywayAdam Powell
08/11/2021, 8:44 PMAdam Powell
08/11/2021, 8:44 PMAdam Powell
08/11/2021, 8:45 PMcarbaj0
08/12/2021, 3:59 AMcarbaj0
08/12/2021, 4:01 AMButtonPrimaryBlue (text = "Button", onClick = {})
This component already has some colors and shapes applied, which is what causes the component to be called like that.
But I find the case that sometimes I want it to fit the size of the text and other times to fit its container (a Row for example)carbaj0
08/12/2021, 4:48 AMRow {
Box(modifier = Modifier.weight(1f)) {
PrimaryBlueButton(
onClick = { },
text = "Click",
fillMaxWith = true
)
}
Box(modifier = Modifier.weight(1f)) {
PrimaryBlueButton(
onClick = { },
text = "Click",
fillMaxWith = true
)
}
}
carbaj0
08/12/2021, 4:48 AMAdam Powell
08/12/2021, 1:36 PMcarbaj0
08/12/2021, 3:25 PMAdam Powell
08/12/2021, 3:31 PMAdam Powell
08/12/2021, 3:33 PMModifier.background
isn't part of some defined box model for UI elements, it just says, "at this point, draw something behind the modified content."carbaj0
08/12/2021, 3:40 PMAdam Powell
08/12/2021, 3:43 PMColton Idle
08/12/2021, 3:51 PMcarbaj0
08/12/2021, 4:01 PMcarbaj0
08/12/2021, 4:02 PMColton Idle
08/12/2021, 4:16 PMColton Idle
08/12/2021, 4:17 PMAdam Powell
08/12/2021, 4:17 PMI would just put an optional weight argument with a sensible default value.you can't do this since
Modifier.weight
is provided by DSL scopes from specific containers onlyAdam Powell
08/12/2021, 4:18 PMAdam Powell
08/12/2021, 4:19 PMAdam Powell
08/12/2021, 4:21 PMAdam Powell
08/12/2021, 4:21 PMAdam Powell
08/12/2021, 4:22 PMAdam Powell
08/12/2021, 4:22 PMColton Idle
08/12/2021, 4:24 PMAdam Powell
08/12/2021, 4:26 PMmodifier: Modifier = Modifier
in the parameter list and then use modifier.foo()...
instead of Modifier.foo()...
in the implementation code of a composable that emits a single root UI element