Can anyone from google please do something about t...
# compose
t
Can anyone from google please do something about this? It is in draft state since Mar 2023. We really need this to complete migration from M2 to M3 https://github.com/google/accompanist/pull/1543
i
If you really need it, have you considered building your own implementation? There aren't any private APIs being used, but maybe that exploration might expose the issues with the bottom sheet APIs themselves that have been the focus on fixing since March 2023. Filing bugs on any of the blocking issues you find on bottom sheets themselves on the issue tracker would really help get those APIs in the best state possible before building something on top of them (you'll note just how many issues in that repository are the current bottom sheet APIs not working well...)
👍 1
a
I'm not sure what the point of accompanist navigation-material is. Docs give an example of bottom sheets, but…is that it? Does it add anything over compose navigation other than allowing opening sheets from a navigator?
I can see how it was useful in M2, but M3 doesn't need separate layouts just for sheets. You can control showing them fairly easily, with state variables for example (similar to AlertDialog).
t
other than allowing opening sheets from a navigator?
@ascii that’s what we are using it for
a
I may be missing some context specific to your project, but I use navigation-compose with M3, ModalBottomSheet, etc, and I've never felt the need to control sheets as a navigation element. You'd want to show sheets either in response to a user event:
Copy code
var showSheet by remember { mutableStateOf(false) }
Button({ showSheet = true })
if (showSheet) ModalBottomSheet({ showSheet = false }) {
    SheetContent()
}
or automatically, for example to display an error:
Copy code
var error by remember { mutableStateOf<String?>(null) }
MainContent(onError = { error = it })
if (error) ModalBottomSheet({ error = null }) {
    SheetContent()
}
Of course, you can also pass your own ModalBottomSheetState if you want to do more than just show/hide (e.g. partial expand).
i
The main benefit is giving your bottom sheet its own
Lifecycle
, ViewModels, and saved state that is tied to the existence of the bottom sheet (i.e., gets cleaned up when the bottom sheet is dismissed)
👍 1
You're right that M3 bottom sheets act much more like any
Dialog
in that a lot of the time, you don't actually need all of that and can just embed it in your destination itself. We make this same point of "do you really need it as a separate destination" in the docs on dialog destinations: https://developer.android.com/reference/kotlin/androidx/navigation/compose/package-summary#(androidx.navigation.NavGraphBuilder).dialog(kotlin.String,kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.window.DialogProperties,kotlin.Function1)
j
Apologies for this PR not being updated in a long time. As Ian pointed out, we realized we need to wait for the M3 sheet APIs to be a bit more stable. We should have communicated this much better though, I will add a disclaimer.