raamcosta / compose-destinations

Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
https://composedestinations.rafaelcosta.xyz
Apache License 2.0
3.18k stars 132 forks source link

BottomSheet Expanded #130

Open captainhaddockfr35 opened 2 years ago

captainhaddockfr35 commented 2 years ago

Hi,

I would like to use the BottomSheet Style. It works but I would like the sheet to open in expanded state, as is possible with androidx.compose.material.ModalBottomSheetLayout but not with accompanist. If I use com.google.accompanist.navigation.material.ModalBottomSheetLayout, the BottomSheet opens fine, but I can't open it in full screen (Expanded). If I use androidx.compose.material.ModalBottomSheetLayout I can tell it to open as Expanded but the bottomSheet does not open.

Did you have an idea ?

raamcosta commented 2 years ago

Hey 👋

yeah this is a known issue with accompanist bottom sheet. There is not much to be done I believe other than opening an issue on accompanist to pressure them to implement the functionality.

raamcosta commented 2 years ago

You can always just use the bottom sheet from material of course. The difference is that it won’t be registered as a destination in the navigation host, but as long as you have a state saved like on SavedStateHandle, you should be fine, to resume the bottom sheet for a given screen. Of course it won’t be as standalone thing, but you can make it work for sure 🙂

rudradave1 commented 2 years ago

Here is a workaround if you are using ModalBottomSheet.

        val sheetState = rememberModalBottomSheetState(
                    initialValue = ModalBottomSheetValue.Hidden,
                    skipHalfExpanded = true,
                    confirmStateChange = { false }
                )
        val bottomSheetNavigator = remember { BottomSheetNavigator(sheetState) }
        navController.navigatorProvider += bottomSheetNavigator
livotov commented 1 year ago

Just a note - for "confirmStateChange = { false }" it is better to return "true" as otherwise you'll be unable to close the bottom sheet by swiping it down

AttilaAKINCI commented 7 months ago

Here is a workaround if you are using ModalBottomSheet.

        val sheetState = rememberModalBottomSheetState(
                    initialValue = ModalBottomSheetValue.Hidden,
                    skipHalfExpanded = true,
                    confirmStateChange = { false }
                )
        val bottomSheetNavigator = remember { BottomSheetNavigator(sheetState) }
        navController.navigatorProvider += bottomSheetNavigator

I believe, not possible for MT3