Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Created June 13, 2021 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongbeomi/b7200cf3b9ace83409a776c08dd60f1c to your computer and use it in GitHub Desktop.
Save hongbeomi/b7200cf3b9ace83409a776c08dd60f1c to your computer and use it in GitHub Desktop.
@ExperimentalFoundationApi
@Composable
fun CharacterList(
characterFlow: Flow<List<Character>>,
modifier: Modifier = Modifier,
onClickItem: (Character) -> Unit = {}
) {
val characterList by getLifecycleAwareState(flow = characterFlow, initialValue = listOf())
LazyVerticalGrid(
cells = GridCells.Fixed(3),
modifier = modifier
) {
items(characterList) {
CharacterItem(
character = it,
modifier = Modifier.height(240.dp),
onClick = onClickItem
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment