-
-
Save skydoves/6117dadaa2ab39550a399bb54d14a4a8 to your computer and use it in GitHub Desktop.
consume_list_ui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun ConsumeList( | |
listUi: ListUi, | |
modifier: Modifier = Modifier, | |
) { | |
val layoutType = listUi.layout.toLayoutType() | |
when (layoutType) { | |
LayoutType.GRID -> { | |
LazyHorizontalGrid( | |
modifier = modifier | |
.fillMaxWidth() | |
.height(listUi.itemSize.heightDp()), | |
rows = GridCells.Adaptive(minSize = listUi.itemSize.widthDp()), | |
horizontalArrangement = Arrangement.spacedBy(12.dp) | |
) { | |
items(items = listUi.items, key = { it.url }) { imageUi -> | |
Box( | |
modifier = Modifier | |
.clip(RoundedCornerShape(8.dp)) | |
.size( | |
width = listUi.itemSize.widthDp(), | |
height = listUi.itemSize.widthDp() | |
) | |
) { | |
ConsumeImageUi( | |
imageUi = imageUi.copy(size = listUi.itemSize), | |
) | |
} | |
} | |
} | |
} | |
LayoutType.COLUMN -> Unit // custom implementation | |
LayoutType.ROW -> Unit // custom implementation | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment