https://kotlinlang.org logo
#compose
Title
# compose
d

Deepak Gahlot

03/08/2021, 4:24 PM
Hello I'm trying to implement a bottom-sheet which will launch on the icon click on the top bar. But i'm getting a weird result below are the details
here is the code snippet
Copy code
@ExperimentalMaterialApi
@Composable
private fun QuestionnaireTopBar(
    questionIndex: Int,
    totalQuestionsCount: Int
) {
    val bottomSheetScaffoldState = rememberBottomSheetScaffoldState(
        bottomSheetState = BottomSheetState(BottomSheetValue.Collapsed)
    )
    Column() {
        Row(
            modifier = Modifier.fillMaxWidth(),
            horizontalArrangement = Arrangement.SpaceBetween,
            verticalAlignment = Alignment.CenterVertically
        ) {
            TopAppBarTitle(
                modifier = Modifier
                    .padding(start = 20.dp)
            )
            Row() {
                BottomSheet(bottomSheetScaffoldState = bottomSheetScaffoldState)
                IconButton(
                    onClick = { },
                ) {
                    Icon(
                        painterResource(id = R.drawable.ico_expand),
                        contentDescription = "expand"
                    )
                }
            }
        }
    }
}

@ExperimentalMaterialApi
@Composable
fun BottomSheet(bottomSheetScaffoldState: BottomSheetScaffoldState) {
    val coroutineScope = rememberCoroutineScope()
    BottomSheetScaffold(
        scaffoldState = bottomSheetScaffoldState,
        sheetContent = {
        },
        sheetPeekHeight = 0.dp
    ) {
        IconButton(
            onClick = {
                coroutineScope.launch {
                    if (bottomSheetScaffoldState.bottomSheetState.isCollapsed) {
                        bottomSheetScaffoldState.bottomSheetState.expand()
                    } else {
                        bottomSheetScaffoldState.bottomSheetState.collapse()
                    }
                }
            },
        ) {
            Icon(
                painterResource(id = R.drawable.ic_list),
                contentDescription = "list"
            )
        }
    }
}
The UI looks like this
I was expecting something like this
2 Views