feat(Android, FormSheet v5): Add support for fractional detents#4251
Open
t0maboro wants to merge 10 commits into
Open
feat(Android, FormSheet v5): Add support for fractional detents#4251t0maboro wants to merge 10 commits into
t0maboro wants to merge 10 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds fractional detent support for the new Android FormSheet (gamma) by mapping a JS detents array into BottomSheetBehavior configuration, while also addressing visual/insets issues (enter-animation flicker on API < 30 and non-edge-to-edge dialog layout).
Changes:
- Plumbs
detentsfrom the RN prop layer (FormSheetHostViewManager/FormSheetHost) intoFormSheetConfigandFormSheetDialogManager. - Introduces
FormSheetDetents+FormSheetBehaviorControllerto validate detent input and apply correspondingBottomSheetBehaviorparams (peek/half-expanded/expanded/maxHeight) with a forced re-layout. - Forces edge-to-edge rendering in
FormSheetDialogand disables Material’s insets animation callback to prevent translationY conflicts with the custom enter animation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetHostViewManager.kt | Implements detents prop parsing from ReadableArray into a Kotlin list. |
| android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetHost.kt | Stores detents on the host and passes them into FormSheetConfig. |
| android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetDialogManager.kt | Resolves detents, triggers reconfiguration on open/config change, updates container height, and disables Material insets animation callback. |
| android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetDialog.kt | Forces edge-to-edge drawing for consistent dimming + layout across API levels. |
| android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetDetents.kt | Adds detent validation + helpers for computing pixel heights and container sizing. |
| android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetConfig.kt | Extends config with detents. |
| android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetBehaviorController.kt | Stateless mapper from resolved detents to BottomSheetBehavior properties. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds configurable detents to the new FormSheets on Android. Due to the native limitations, it allows passing 0-3 detents from JS, which are parsed to BottomSheetBehavior params (peek/half-expanded/expanded/max-height).
I am introducing a
FormSheetBehaviorControllerwhich is a stateless mapper from a resolved detent config toBottomSheetBehavior, forcing a fresh layout pass so the behavior re-settles to the new detent configuration.Additionally, I am making some bugfixes related to or exposed by introducing the sheet detents mechanism.
BottomSheetBehaviorregisters aWindowInsetsAnimationCallbackwhich updatestranslationYand is causing the sheet to jump during the enter animation (I am modifying translation on a custom slide-in animation). We clear that callback after the first layout, because we manage insets ourselves via a fixed container height, preventing the conflict.BottomSheetDialogedge-to-edge when the theme opts in, and the nav bar is translucent; otherwise, the CoordinatorLayout (and our full-bleed dimming view) is inset below the status bar. We now force edge-to-edge on the dialog window on every API level.Closes: https://github.com/software-mansion/react-native-screens-labs/issues/1551
Changes
FormSheetBehaviorControllerresponsible for mapping the raw JS detents array into specificBottomSheetBehaviorproperties.WindowInsetsAnimationCallback, unblocking our customtranslationYenter-animation.onAttachedToWindow()inFormSheetDialogon both the window decor and the internal Material containers (R.id.container,R.id.coordinator), ensuring the dimming view covers the status bar area and the FormSheetContainer space is predictable across different API levels.Before & after - visual documentation
detents.mov
Test plan
Tested on the base example &
Checklist