pref: `VerticalGrid` 性能

This commit is contained in:
HuanCheng65 2023-07-18 17:50:25 +08:00
parent fa7edbc326
commit dff92beadc
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
1 changed files with 3 additions and 2 deletions

View File

@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -113,9 +114,9 @@ fun VerticalGrid(
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
content: GridScope.() -> Unit
) {
val gridScope = GridScopeImpl().apply(content)
val gridScope = remember(content) { GridScopeImpl().apply(content) }
Column(modifier = modifier, verticalArrangement = verticalArrangement) {
val rows = calcRows(column, gridScope.items)
val rows = remember(column, gridScope) { calcRows(column, gridScope.items) }
rows.forEach {
Row(
verticalAlignment = Alignment.CenterVertically,