Created
June 27, 2022 17:06
-
-
Save aqua30/514d711fb11c7d6044e58519e263e20f to your computer and use it in GitHub Desktop.
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 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