Код: Выделить всё
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Screen() {
val configuration = LocalConfiguration.current
val screenHeight = configuration.screenHeightDp.dp
var sheetHeight by remember {
mutableStateOf(0.dp)
}
val sheetState = rememberStandardBottomSheetState(
initialValue = SheetValue.Hidden,
confirmValueChange = {
sheetHeight = when (it) {
SheetValue.Hidden -> 0.dp
SheetValue.Expanded -> screenHeight
SheetValue.PartiallyExpanded -> screenHeight / 2
}
true
},
skipHiddenState = false,
)
val scaffoldState = rememberBottomSheetScaffoldState(bottomSheetState = sheetState)
val coroutineScope = rememberCoroutineScope()
BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetPeekHeight = sheetHeight,
sheetContent = {
Box(
modifier = Modifier
.fillMaxSize()
) {
// content
}
}
) {
Button(
modifier = Modifier.height(50.dp),
onClick = {
coroutineScope.launch {
scaffoldState.bottomSheetState.partialExpand()
}
},
) {
Text(text = "Click me")
}
}
Я также пытался использовать его полностью без установки листаPeekHeight, но у него частично развернутая высота намного меньше половины экрана: видео
Подробнее здесь: https://stackoverflow.com/questions/786 ... -it-should