Skip to content

feat(Android, FormSheet v5): Add onDetentChanged support#4292

Open
t0maboro wants to merge 6 commits into
mainfrom
@t0maboro/on-detent-change-android
Open

feat(Android, FormSheet v5): Add onDetentChanged support#4292
t0maboro wants to merge 6 commits into
mainfrom
@t0maboro/on-detent-change-android

Conversation

@t0maboro

@t0maboro t0maboro commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces support for the onDetentChanged event in the FormSheet. It reports the index of the newly settled detent.

Closes: https://github.com/software-mansion/react-native-screens-labs/issues/1561

Changes

  • Android's BottomSheetBehavior operates on strict states, so the dynamic mapping in FormSheetBehaviorController safely translates these states into the corresponding detents array index depending on the current detent count configuration.
  • Bound FormSheetDetentChangedEvent with JS

Before & after - visual documentation

detent-change.mov

Test plan

Marked SFT as applicable on Android.

Checklist

  • Included code example that can be used to test this change.
  • For visual changes, included screenshots / GIFs / recordings documenting the change.
  • For API changes, updated relevant public types.
  • Ensured that CI passes

@t0maboro t0maboro changed the base branch from main to @t0maboro/formsheet-lifecycle-events-android July 8, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Android support for the FormSheet onDetentChanged event (already present on iOS), emitting the newly settled detent index to JS, and introduces a Single Feature Test (SFT) scenario to validate the behavior.

Changes:

  • Android: wired a new FormSheetDetentChangedEvent through the host view manager/emitter chain and mapped BottomSheetBehavior state changes to detent indices.
  • JS/Types: updated FormSheet prop docs to reflect cross-platform availability.
  • Apps (SFT): added an onDetentChanged test scenario and made it available on both Android and iOS.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/components/gamma/modals/form-sheet/FormSheet.types.ts Removes the iOS-only platform annotation for onDetentChanged to reflect Android support.
apps/src/tests/single-feature-tests/form-sheet/test-form-sheet-on-detent-changed/scenario.md Adds manual test instructions for verifying onDetentChanged.
apps/src/tests/single-feature-tests/form-sheet/test-form-sheet-on-detent-changed/scenario-description.ts Registers the new SFT scenario metadata for Android + iOS.
apps/src/tests/single-feature-tests/form-sheet/test-form-sheet-on-detent-changed/index.tsx Implements the test screen that displays the active detent index based on onDetentChanged.
apps/src/tests/single-feature-tests/form-sheet/index.ts Exposes the new scenario from the form-sheet SFT index.
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetHostViewManager.kt Exports the new direct event registration info for onDetentChanged.
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetHostEventEmitter.kt Adds an emitter method to dispatch detent change events to JS.
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetHost.kt Wires dialog detent changes to the React event emitter.
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetDialogManager.kt Passes the detent change callback into the behavior controller and manages callback lifecycle.
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetDetentChangedEvent.kt Introduces the Android event payload for detent index changes.
android/src/main/java/com/swmansion/rnscreens/gamma/modals/formsheet/FormSheetBehaviorController.kt Listens to BottomSheet state changes and maps them to detent indices for event emission.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@t0maboro t0maboro changed the title feat(Android, FormSheet v5): Add onDetentChanged support [REBASE IN PROGRESS] feat(Android, FormSheet v5): Add onDetentChanged support Jul 8, 2026
@t0maboro t0maboro force-pushed the @t0maboro/formsheet-lifecycle-events-android branch from ce2e09c to abd49b0 Compare July 8, 2026 12:56
Base automatically changed from @t0maboro/formsheet-lifecycle-events-android to main July 9, 2026 12:33
@t0maboro t0maboro force-pushed the @t0maboro/on-detent-change-android branch from f61e1fe to 49ce734 Compare July 9, 2026 14:50
@t0maboro t0maboro changed the title [REBASE IN PROGRESS] feat(Android, FormSheet v5): Add onDetentChanged support feat(Android, FormSheet v5): Add onDetentChanged support Jul 9, 2026
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.

2 participants