1 | initial version |
To use the Android Compose ModalBottomSheetLayout instead of a DialogFragment, you need to follow these steps:
implementation "androidx.compose.material:material:1.0.3"
@Composable
fun MyBottomSheetContent() {
// your content goes here
}
var isBottomSheetOpen by remember { mutableStateOf(false) }
ModalBottomSheetLayout(
sheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden
),
sheetContent = { MyBottomSheetContent() }
) {
// your main content goes here
}
Button(
onClick = { isBottomSheetOpen = true },
content = { Text("Open Bottom Sheet") }
)
LaunchedEffect(isBottomSheetOpen) {
if (isBottomSheetOpen) {
sheetState.show()
} else {
sheetState.hide()
}
}
With these steps, you can use the Android Compose ModalBottomSheetLayout to display your content in a bottom sheet instead of a DialogFragment.