```@Composable private fun PeopleScreen() { va...
# compose
m
Copy code
@Composable
private fun PeopleScreen() {
    val viewModel: PeopleViewModel2 = viewModel()

    val viewState = viewModel.peopleList.collectAsState(initial = emptyList())
    val listItems: List<PeopleItem> by viewState

    LazyColumn(
        contentPadding = PaddingValues(horizontal = 8.dp, vertical = 16.dp),
        modifier = Modifier.padding(bottom = 56.dp)
            .fillMaxWidth()
    ) {
        for (item in listItem) {
            item(key = item.id) {
                PeopleItem(
                    item = item,
                    onFavouriteClicked = { viewModel.onFavouriteClicked(item) }
                )
                Spacer(modifier = Modifier.padding(bottom = 8.dp))
            }
        }
    }
}
t
To make the composable more reusable you could provide the peopleList and a callback for the favoriteClick as a parameter.
Copy code
private fun PeopleScreen(peopleList: Flow, favouriteClicked: (PeopleItem) -> Unit)
But of course it is your decision.
m
no. This composable represents a screen, so it is the top level composable. The clicks are redirected to the viewModel because there is no composable higher, as i think it should be
👍 1