Skip to content

refactor(android): use BottomSheetDialogFragment instead of BottomSheetDialog#342

Merged
lodev09 merged 7 commits intomainfrom
refactor/dialog-fragment
Dec 19, 2025
Merged

refactor(android): use BottomSheetDialogFragment instead of BottomSheetDialog#342
lodev09 merged 7 commits intomainfrom
refactor/dialog-fragment

Conversation

@lodev09
Copy link
Copy Markdown
Owner

@lodev09 lodev09 commented Dec 19, 2025

Summary

Refactors Android implementation to use BottomSheetDialogFragment instead of BottomSheetDialog for better lifecycle management and flexibility.

Changes

New Files

  • TrueSheetDialogFragment.kt in core/: Custom BottomSheetDialogFragment that handles:
    • Dialog creation with proper theming (edge-to-edge support)
    • BottomSheetBehavior configuration and callbacks
    • Background styling with corner radius
    • Grabber view management
    • Back press handling

Modified Files

  • TrueSheetViewController.kt: Refactored to use the new fragment
    • Implements TrueSheetDialogFragmentDelegate for callbacks
    • Fragment shown via FragmentManager.show()
    • Maintains all existing functionality

Key Implementation Details

  • Custom TrueSheetAnimator handles presentation animation with translationY since onSlide doesn't fire for all sheet configurations
  • isHideable is re-applied after dialog show to fix dismissible prop
  • Footer positioning during keyboard transitions via keyboardDidChangeHeight
  • configureDetents accepts animate param for content size changes

Testing

  • Present/dismiss animations work correctly
  • Child sheets animate properly
  • Keyboard handling works
  • Footer positioning works
  • Dimming works for stacked sheets
  • Dismissible prop works correctly
  • Dragging works
  • react-native-screens modal observer works

…etDialog

- Create TrueSheetDialogFragment in core/ for better lifecycle management
- Refactor TrueSheetViewController to use the new fragment
- Add TrueSheetDialogFragmentDelegate for fragment callbacks
- Maintain all existing functionality (detents, animations, keyboard, stacking)
- Move setupSheetDetents and setupDimmedBackground to onDialogShow
- Clear FLAG_DIM_BEHIND in fragment's onCreateDialog
- Fix footer positioning with post and isPresented check
- Rename setDraggable to updateDraggable to fix JVM signature clash
- Add animate parameter to configureDetents
- Use setPeekHeight with animate flag when sheet is presented
- Remove unnecessary footerView.post wrapper
- Restore translationY logic in animator for child sheets
- Remove duplicate setStateForDetentIndex call in onDialogShow
- Position sheet off-screen before animation starts
- Clean up debug logging
- Re-apply isHideable after dialog show to fix dismissible
- Move isAnimating check to early return in onSlide
- Clean up debug logging
@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
react-native-true-sheet Ready Ready Preview, Comment Dec 19, 2025 0:18am

@lodev09 lodev09 merged commit 7a35fa6 into main Dec 19, 2025
5 checks passed
@lodev09 lodev09 deleted the refactor/dialog-fragment branch December 19, 2025 00:19
@lodev09
Copy link
Copy Markdown
Owner Author

lodev09 commented Dec 19, 2025

🚀 This pull request is included in v3.5.1-beta.1. See Release 3.5.1-beta.1 for release notes.

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.

1 participant