I am new to Android. My Compose function is too la...
# compose
t
I am new to Android. My Compose function is too large, so I have to split it into smaller functions. However, I have an issue when I want to navigate or use the ViewModel in the parent Compose function. I have to pass callbacks multiple times, making the code very messy. I really hope to get help from everyone.
Copy code
@Composable
fun MainScreen(onNavigateProfile:()->Unit) {
    Content(
        searchConversation = {},
        onClickItem = {/*view Model call API*/},
        onClose = {},
        onLoadMore = {},
        onNavigateProfile = {
            onNavigateProfile()
        },
        deleteConversation = {}
    )
}

@Composable
fun Content(
    searchConversation: () -> Unit,
    onClickItem: () -> Unit,
    deleteConversation: (String?) -> Unit,
    onNavigateProfile: () -> Unit,
    onLoadMore: () -> Unit,
    onClose: () -> Unit,
) {
    CommonDrawer(
        listOf<HistoryConversationState>(),
        searchConversation,
        onClickItem,
        deleteConversation,
        onNavigateProfile,
        onLoadMore,
        onClose
    )
}

@Composable
fun CommonDrawer(
    historyConversationState: HistoryConversationState,
    searchConversation: () -> Unit,
    onClickItem: () -> Unit,
    deleteConversation: (String?) -> Unit,
    onNavigateProfile: () -> Unit,
    onLoadMore: () -> Unit,
    onClose: () -> Unit,
){
    Box(modifier = Modifier.clickable {
        onNavigateProfile()
    })

    Text(modifier = Modifier.clickable{
        onClickItem()
    }, text = "callBack hell")
}
🧵 2