Skip to content

Conversation

jbw0033
Copy link

@jbw0033 jbw0033 commented Aug 19, 2025

This commit adds a recipe that demonstrates how to display a navigation destination within a Material ModalBottomSheet.

It introduces BottomSheetSceneStrategy, a SceneStrategy that can be added to a NavDisplay. This strategy checks for specific metadata on a NavEntry to determine if it should be rendered as a bottom sheet.

A new BottomSheetActivity is added to showcase how to use this strategy.

#32

This commit adds a recipe that demonstrates how to display a navigation
destination within a Material `ModalBottomSheet`.

It introduces `BottomSheetSceneStrategy`, a `SceneStrategy` that can be
added to a `NavDisplay`. This strategy checks for specific metadata on a
`NavEntry` to determine if it should be rendered as a bottom sheet.

A new `BottomSheetActivity` is added to showcase how to use this
strategy.
@jbw0033 jbw0033 requested a review from dturner as a code owner August 19, 2025 03:33
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @jbw0033, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new "recipe" demonstrating how to integrate Material Design ModalBottomSheet components with the Nav3 navigation library. It provides a custom SceneStrategy that allows navigation destinations to be displayed as bottom sheets, enhancing UI flexibility for Android applications.

Highlights

  • New BottomSheetSceneStrategy: Introduced BottomSheetSceneStrategy, a custom SceneStrategy for NavDisplay that enables rendering navigation entries as Material ModalBottomSheet components.
  • Metadata-driven Bottom Sheet Display: Implemented a metadata-based mechanism (BottomSheetSceneStrategy.bottomSheet()) to designate specific NavEntry instances for display within a bottom sheet.
  • New Example Activity: Added BottomSheetActivity as a comprehensive example showcasing the practical application and integration of the new bottom sheet navigation strategy.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@jbw0033
Copy link
Author

jbw0033 commented Aug 19, 2025

@ianhanniballake

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new recipe for displaying a navigation destination inside a Material ModalBottomSheet. The implementation is well-structured, adding a BottomSheetSceneStrategy and a corresponding BottomSheetActivity to demonstrate its usage. The code is clear and effectively showcases the feature. I have one minor suggestion to improve adherence to Kotlin's coding conventions.

@alirahimpour89
Copy link

What happens if you have a button in the bottomsheet that pop the bottomsheet from the backstack, would that mean no animation? How would you handle that?

Doing this for Kotlin code syntax
@jbw0033
Copy link
Author

jbw0033 commented Aug 19, 2025

What happens if you have a button in the bottomsheet that pop the bottomsheet from the backstack, would that mean no animation? How would you handle that?

That is something that would be a good feature request to file here for the material team to address.

@alirahimpour89
Copy link

What happens if you have a button in the bottomsheet that pop the bottomsheet from the backstack, would that mean no animation? How would you handle that?

That is something that would be a good feature request to file here for the material team to address.

But is it even possible with the current implementation of nav3 and the scenes? I can think of some ugly hacks but no clean way with the current implementation, that is why I ask here? Maybe I just missed something but I think this receipt show that too because for me the this receipt would not be final without having that animation because it is a pretty common thing if you for example have some kind of menu in the bottom sheet. Because the material 3 bottom sheet has everything it needs to implement it but I don't think the nav3 lib does but I can of course have missed something 🙂

@dturner
Copy link
Collaborator

dturner commented Aug 22, 2025

But is it even possible with the current implementation of nav3 and the scenes?

I don't think this is currently possible and have requested this in https://issuetracker.google.com/440558061.

The issue is that OverlayScenes, which BottomSheetScene is, are not wrapped in an AnimatedContent like normal scenes (source) so when you do backStack.removeLast() from inside the bottom sheet, the NavDisplay immediately removes that scene so it disappears rather than being animated out.

A possible workaround (which I haven't tried) would be to programmatically trigger a back event, this would be handled by ModalBottomSheet's back handler and the normal out animation would run.

@lepicekmichal
Copy link

lepicekmichal commented Aug 22, 2025

I just wrapped the content with this
CompositionLocalProvider(LocalBottomSheetDismiss provides sheetState::hide) {}

Then you use the function instead of your backstack and voila, animation is working, stack is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants