I also pass resources as a parameter. You can check the below examples.
MenuItem.kt
data class MenuItem(
val id: String,
val title: String,
val contentDescription: String,
val icon: Painter
)
Data
@Composable
private fun prepareNavigationDrawerItems(): List<MenuItem> {
val itemsList = arrayListOf<MenuItem>()
itemsList.add(
MenuItem(
id = "contact_us",
title = stringResource(R.string.contact_us),
contentDescription = "Contact Us",
icon = painterResource(id = R.drawable.contact_us)
)
)
return itemsList
}
Final Screen
@Composable
fun MyCompleteDrawer() {
val itemsList = prepareNavigationDrawerItems()
LazyColumn(
modifier = Modifier
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
contentPadding = PaddingValues(vertical = 20.dp)
) {
items(itemsList) { item ->
NavigationListItem(item = item) {
}
}
}
}