What happened to Modifier.weight in alpha04
# compose
g
What happened to Modifier.weight in alpha04
😱 2
😫 1
Copy code
with(ColumnScope) { Modifier.weight(1f) }
g
well that touches a lot of code
r
I guess if you change composable function to be ColumnScope.MyButton then you get it automatically. Also if you use it in Column composable for example.
☝️ 2
z
I think that’s the point.
Modifier.weight
doesn’t have any effect outside of `Column`/`Row` composables, so this change is probably intended to help prevent using it where it’s pointless.
3
Or just change your child composables to take
Modifier
parameters, and pass the weight modifier in from wherever the `Column`/`Row` is.
3
💡 1
g
The problem is inside a Column you still have to do a with statement. It makes the code longer needlessly.
This works:
Copy code
Column(with(ColumnScope) {Modifier.weight(.15f) }) {}
This does not:
Copy code
Column(Modifier.weight(.15f)) {}
Why inside a column would I need to declare this?
Just a lot of busy work.
If I add scope to the functions is the easiest way to clean it up. Probably a smart thing to do.
z
Copy code
Column(with(ColumnScope) {Modifier.weight(.15f) }) {}
Here the
weight
modifier only does something if the parent of this
Column
is also a column or row. It doesn’t matter which composable you apply the modifier too, it matters what its parent is.
e.g. This gives you two columns, side-by-side, which each take up half the width:
Copy code
Row {
  Column(Modifier.weight(.5f)) { … }
  Column(Modifier.weight(.5f)) { … }
}
This gives you two columns which are stacked on top of each other, with whatever size they want to be (that is, the weight modifier has no effect:
Copy code
Box {
  Column(with(ColumnScope) { Modifier.weight(.5f) }) { … }
  Column(with(RowScope) { Modifier.weight(.5f) }) { … }
}