0

Opened by clicking a FAB, I have an Add Item Dialog which includes an option to assign an image to the shopping list item. Is it possible to implement a Bottom Modal Sheet with options for camera capture, etc. at the bottom of the Dialog?

Raj Narayanan
  • 2,443
  • 4
  • 24
  • 43
  • What do you want with the `bottomsheetdialog?` it must be inside the dialog or default position? Its better if you tried it first – Cyrille Con Morales May 23 '22 at 00:59
  • Inside the `bottomsheetdialog`, I want to have options for using the camera, gallery, or file system to assign the shopping list item an image. I tried this already but it was opening the sheet at the bottom of the activity screen rather than within the Dialog Composable. Unfortunately, I don't have my original implementation code. – Raj Narayanan May 23 '22 at 01:16

1 Answers1

1

You can use a ModalBottomSheetLayout inside you're dialog, put you're bottom sheet composable inside the sheetContent part of this layout, and the rest of you're dialog in the content part of this layout, and then manipulate the open and closed state of the bottom sheet dialog with the sheetState

It will give you something like that :

// Create the sheet state
val mySheetState = rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden)

// Add the layout
ModalBottomSheetLayout(
    sheetContent = {
        // You're camera caption button here, or anything else 
    },
    sheetState = mySheetState
) {
    // You're dialog content here
}

// Show or hide you're bottom sheet dialog
LaunchedEffect(Unit) { mySheetState.hide() }
LaunchedEffect(Unit) { mySheetState.show() }
  • This does not open the bottom sheet inside the dialog, it opens it inside the parent screen behind it. Please look at my other question with the implementation code. https://stackoverflow.com/q/72491867/10259491 – Raj Narayanan Jun 03 '22 at 16:34