https://kotlinlang.org logo
#compose
Title
# compose
c

Chris Fillmore

08/06/2021, 9:19 PM
I have filed a bug with Accompanist re: navigation-material https://github.com/google/accompanist/issues/617
i

Ian Lake

08/06/2021, 10:17 PM
Can you explain what user experience you're trying to accomplish by putting a bottom sheet over an empty screen (since there's no destination below the bottom sheet)?
1
j

jossiwolf

08/07/2021, 8:15 AM
Apart from that - the issue here is the bottom sheet being empty 🙂
c

Chris Fillmore

08/09/2021, 10:39 AM
My use case is in a camera Activity. The camera preview is on the screen at all times, so it sits outside the NavHost, like this:
Copy code
setContent {
  CameraPreview()
  NavHost(...) {
    ...
  }
}
Aha, Jossi is right. That didn’t occur to me, because in my actual app I have a bunch of stuff in the bottom sheet. But the code amounted to something like this:
Copy code
bottomSheet(...) {
  for (item in <empty list>) {
    ...
  }
}
My bad.
👍 1
Jossi, is it practical to add support for bottom sheets as start destinations? I see the issue now that, without being able to pop the stack, dismissing the modal would go nowhere. perhaps the
BottomSheetNavigator.Destination
could accept a fallback route to navigate to, in cases where the bottom sheet is itself at the bottom of the stack? Or, instead, add some behaviour where the bottom sheet can be set as startDestination, with another destination underneath? Reason I ask is, on iOS we have roughly this capability, by opening a bottom-sheet-style modal in a
viewDidLoad
callback. I’d like to have some similar capability on Android, so that I can open a bottom sheet when an Activity initially starts.
j

jossiwolf

08/09/2021, 4:21 PM
I don't think that makes a ton of sense.
BottomSheetNavigator
is only aware of entries on its state's back stack, which means there are only entries with `BottomSheetNavigator.Destination`s on there. The
NavController
keeps track of the global back stack but the navigator isn't aware of the
NavController
. I think it would make more sense to have your Activity (or whatever is under the sheet) as startDestination and then navigate when the Activity starts. But cc @Ian Lake cause I'd love to hear his thoughts about
FloatingWindow
destinations as start destinations
c

Chris Fillmore

08/09/2021, 4:22 PM
Thanks for the feedback. Yeah I’m open to suggestions on how to handle this use case
i

Ian Lake

08/09/2021, 4:26 PM
It sounds like your
CameraPreview
should be the start destination of your graph