yousefa2
07/26/2021, 2:09 PMRow
, Column
or Box
depending on what I want. You get additional modifiers based on the scope you are in..i.e BoxScope.Modifier.matchsParentSize()
, RowScope.Modifier.weight
..etc.
I am looking into a way to get these values from the server. Since I don’t know which layout will be rendering at run-time.. I can’t have a scope.
I have looked into something like
fun MyCustomLayout(someLayoutEnum: LayoutTypeEnum, content: @Composable () -> Unit) {
// do some work here
}
Which works to define the layout at run-time but you would still be stuck not knowing the scope and not being able to use RowScope.Modifier.weight
for example.
What I am going with right now is copying the Jetpack compose team logic of using a MeasurePolicy + Layout, which is either internal or private, and modifying it to accept a list of modifiers for each child.
val measurePolicy = rowMeasurePolicy(horizontalArrangement,verticalAlignment, modifiers) // This could be columnMeasurePolicy or boxMeasurePolicy
Layout(
content = { content() },
measurePolicy = measurePolicy,
modifier = modifier
)
My question is, does anyone know a better way of doing this?Colton Idle
07/26/2021, 3:32 PMyousefa2
07/26/2021, 5:34 PMModifier.weight
since we don’t know which scope to use of BoxScope
, RowScope
or ColumnScope
Colton Idle
07/26/2021, 5:36 PM