Skip to content

Instantly share code, notes, and snippets.

@aqua30
Created June 27, 2022 17:06
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 aqua30/514d711fb11c7d6044e58519e263e20f to your computer and use it in GitHub Desktop.
Save aqua30/514d711fb11c7d6044e58519e263e20f to your computer and use it in GitHub Desktop.
@Composable
fun HomeScreen(
viewModel: HomeViewModel = viewModel()
) {
val state = viewModel.itemsState
LazyColumn(
modifier = Modifier
.fillMaxSize()
.background(Color.White),
verticalArrangement = Arrangement.Top
) {
items(
items = state,
key = {
it.id
}
) { item ->
ListItem(
item = item,
background = if (item.id % 2 == 0) Color.LightGray else Color.White,
onItemClick = {
viewModel.uiEvent(UiEvent.ItemClick(item))
}
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment