Uli Bubenheimer
05/26/2022, 7:11 PM@Composable
fun ModifiedRow(
modifier: Modifier,
columnModifiers: StableImmutableList<Modifier>,
vararg columns: @Composable (Modifier) -> Unit
) = Row(modifier) {
val composableIter: Iterator<(Modifier) -> Unit> = columns.iterator()
columnModifiers.forEach(composableIter.next()::invoke)
}
The Rows are emitted inside a LazyColumn, so I'd like this to be better performing. I want to use this to align header column widths with data column widths.
What I would like to see is inlining all these composables so that they don't get their own recompose scopes, they're all simple lambdas emitting a single Composable each.
I could manually unroll the vararg, since I use this for exactly 15 columns right now, but I'm holding out for something more elegant. I'm guessing that some advanced Compose magic could pull this off (even though it may be overkill compared to the manual unroll approach).Leland Richardson [G]
05/26/2022, 7:15 PMUli Bubenheimer
05/26/2022, 7:23 PMLazyColumn {
stickyHeader {
Row {
Text("A", Modifier.width(10.dp))
Text("B", Modifier.width(13.dp))
// ...
Text("Z"), Modifier.width(7.dp)
}
}
items(pagingItems) {
Row {
Image(it.a, Modifier.width(10.dp))
Text(it.b, Modifier.width(13.dp))
// ...
Switch(it.z, Modifier.width(7.dp))
}
}
}
Uli Bubenheimer
05/26/2022, 7:26 PMLeland Richardson [G]
05/26/2022, 7:33 PMLeland Richardson [G]
05/26/2022, 7:36 PMUli Bubenheimer
05/26/2022, 7:37 PMUli Bubenheimer
05/26/2022, 7:37 PMLeland Richardson [G]
05/26/2022, 7:38 PMUli Bubenheimer
05/26/2022, 7:43 PMUli Bubenheimer
05/26/2022, 7:43 PMUli Bubenheimer
05/26/2022, 7:45 PMLeland Richardson [G]
05/26/2022, 7:47 PMUli Bubenheimer
05/26/2022, 7:48 PMUli Bubenheimer
05/26/2022, 7:51 PMUli Bubenheimer
05/26/2022, 7:52 PMUli Bubenheimer
05/26/2022, 8:08 PMMap<String, Modifier>
for the widths, which would make it easier to validate their correct usage sites.Uli Bubenheimer
05/26/2022, 8:15 PMUli Bubenheimer
05/26/2022, 8:17 PM