https://kotlinlang.org logo
j

jaqxues

10/18/2020, 7:40 AM
Hello, So I have these simple Preference Items that are causing me some trouble. I set the Spacer with a Modifier of weigth(1f) so the Title (or generally content) of the Preference is always on the left side and the Switch always on the right. However, when I try to use a longer text as description, the Switch gets moved and it does not look correct anymore. I tried setting a padding explicitly and other stuff, which did not work as expected.
g

gsala

10/18/2020, 9:24 AM
I would try to put the weight modifier on the Column and remove the Spacer
j

jaqxues

10/18/2020, 11:13 AM
Copy code
@Composable fun SplitCard(
    modifier: Modifier = Modifier,
    left: @Composable -> Unit,
    right: @Composable -> Unit
) { ... }
This is the function I made out of it. How can I make it behave like
Modifier.weight(1f)
for left? Wrapping it around another composable? What Composable should I use?
Surface
adds a background color, so that is out. This is the implementation I have. How can I apply the Modifier to left? Can I wrap it in a
g

gsala

10/18/2020, 11:28 AM
I tried this
j

jaqxues

10/18/2020, 11:40 AM
,,, yes, but the column itself is the
left
parameter, cant modify its Modifier
This is the code, how can i move the Modifier.weight out of the usage and put it in the "base" Composables.
g

gsala

10/18/2020, 1:23 PM
Not sure what the best pattern is in this case. You could always wrap the
left()
with
Box(modifier = Modifier.weight(1f) { left() }
j

jaqxues

10/18/2020, 1:26 PM
yeah well guess ill end up with that
3 Views