I want to have a composable with that essentially takes in another compasable (slot) but pads it on the left and right and adds a Text on top of it. This is what I came up with but I can't actually call
content(modifier.padding(horizontal = 16.dp))
. Is the way around this just to nest the context in a Box/Column and apply padding to that?
I did look into the Scaffold source but I am admittedly a little bit lost.
Adam Powell you responded "Yes", but just wanted to see if you could confirm whether a Box would work or not. I can't get it to work because of ColumnScope... but should I change ColumnScope or should I just use a Column instead of a Box?
1 year ago
You can always add another Box around your Column as an implementation detail. Kind of depends if you want a child to opt out (i.e., not apply your modifier if it wants to go edge to edge) or if you want to make it mandatory
1 year ago
If you content needs ColumnScope you have to encapsulate it into a column. Otherwise you could also forward the BoxScope
I don't want the child to be able to opt out. So I think I will just wrap it in a column and be done with it.@Timo Drick how would I implement your original suggestion? I understand how wrapping in a column would work, but I'm curious how I could do it without that using the PaddingValues technique you suggested.