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

Djuro

03/11/2024, 3:00 PM
Hello everyone, hope you are all doing well. I have a question. How can I have `BottomSheetScaffold`'s
sheetPeekHeight
be so that it fills the remaining space of the scaffold? I don't want a fixed value. I just want to have it as a
Column
and then fill the whole screen when user drags up. Any ideas?
Current solution I have for this is one I don't really like but here you go Note: you need to explicitly specify
height
of all your components on the screen. I used
BoxWithConstraints
to get maxHeight
Copy code
BoxWithConstraints {
        val boxWithConstraintsScope = this
        Column(modifier = modifier.fillMaxSize().padding(horizontal = 10.dp)) {
            Text(text = "content outside the bottom sheet", modifier = Modifier.height(20.dp))
        }
        BottomSheetScaffold(
            modifier = Modifier.fillMaxHeight(),
            scaffoldState = sheetState,
            sheetContent = {
                Text("Bottom sheet content", modifier = Modifier.fillMaxHeight())
            },
            sheetPeekHeight = boxWithConstraintsScope.maxHeight - 20.dp,
            sheetContainerColor = MaterialTheme.colorScheme.primary,
            sheetShape = RectangleShape,
        ) {
            // no content, sheet should always be displayed
        }
    }
2 Views