Commit Graph

22 Commits

Author SHA1 Message Date
lodev09
acdd9e4cf4
chore: update example deps 2025-12-28 08:20:08 +08:00
lodev09
0734cc3163
fix(android): fix animated sheet dismiss with keyboard shown 2025-12-27 04:08:04 +08:00
lodev09
48d8ceb788
docs: add docs about autofocus input behavior 2025-12-27 02:59:31 +08:00
lodev09
30f9d1b7fb
fix(android): wait for window attachment before initial presentation 2025-12-27 01:00:02 +08:00
lodev09
a7ac1d7839
fix(android): add safe value for halfExpandedRatio 2025-12-26 22:55:26 +08:00
Jovanni Lo
b09440d548
fix(ios): use native backgroundEffect for blur on iOS 26.1+ (#350)
* fix(ios): use native backgroundEffect for blur on iOS 26.1+

- Extract blur style mapping into BlurUtil
- Refactor setupBackground and setupGrabber into helper methods
- Add sheet getter for cleaner code
- Use native UIBlurEffect on backgroundEffect when only blurTint is set (iOS 26.1+)

* refactor: rename blurTint to backgroundBlur
2025-12-25 17:59:55 +08:00
lodev09
3f78fe5423
fix(ios): ignore TrueSheetView in scroll view pinning traversal 2025-12-23 03:51:06 +08:00
lodev09
2e4494024f
docs: update docs 2025-12-22 00:57:12 +08:00
lodev09
cece31ba27
fix(android): parent stacking after rn-screen dismissed 2025-12-21 23:00:35 +08:00
Jovanni Lo
4b02ca77f6
refactor(android): replace DialogFragment with CoordinatorLayout (#344)
* docs: add planning doc

* refactor(android): migrate from DialogFragment to CoordinatorLayout

This solves the touch lag issue when TrueSheet is presented over interactive
components like Maps. The sheet now stays in the same activity window instead
of a separate dialog window.

Changes:
- Add TrueSheetCoordinatorLayout to host sheet and dim view
- Add TrueSheetBottomSheetView with BottomSheetBehavior
- Refactor TrueSheetViewController to use CoordinatorLayout approach
- Update TrueSheetDimView for in-hierarchy usage with touch handling
- Remove TrueSheetDialogFragment (no longer needed)
- Remove unused dialog styles and animations

* fix(android): animate sheet on present using BottomSheetBehavior

* fix(android): animate sheet on present when not dismissible

* refactor(android): simplify dismiss animation using ViewPropertyAnimator

* docs: update AGENTS.md with new Android architecture

* fix(android): prevent duplicate initial present on re-mount

* fix(android): fix keyboard handling and parent sheet translation

* fix(android): prevent parent sheet layout reset when keyboard shows

- Add TrueSheetBottomSheetViewDelegate with isTopmostSheet property
- Skip onLayout for parent sheets to prevent BottomSheetBehavior from
  resetting translationY during system layout passes
- Refactor TrueSheetCoordinatorLayout.Delegate to standalone interface

* fix(android): preserve parent sheet translation during keyboard transitions

Override setTranslationY in TrueSheetBottomSheetView to prevent
keyboard inset animations from resetting parent sheet translation to 0.
Parent sheets (non-topmost) now maintain their translation value.

* refactor(android): rename TrueSheetDialogObserver to TrueSheetStackManager

* refactor(android): remove edgeToEdgeFullScreen prop

* fix(android): prevent sheet from showing during navigation within modal

* fix(android): clamp detent heights to available screen space

* fix(android): post when initialDetentAnimated is false
2025-12-21 16:10:23 +08:00
lodev09
e6b6c36a2e
fix(android): keep sheet at target position during non-animated present 2025-12-20 11:46:22 +08:00
Jovanni Lo
7a35fa6bfb
refactor(android): use BottomSheetDialogFragment instead of BottomSheetDialog (#342)
* fix(android): restore original code

* refactor(android): use BottomSheetDialogFragment instead of BottomSheetDialog

- 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)

* fix(android): fix dialog fragment presentation issues

- 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

* fix(android): animate sheet on content size change

- Add animate parameter to configureDetents
- Use setPeekHeight with animate flag when sheet is presented
- Remove unnecessary footerView.post wrapper

* fix(android): position footer during keyboard transitions

* fix(android): restore translationY animation for present

- 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

* fix(android): fix dismissible behavior and clean up onSlide

- Re-apply isHideable after dialog show to fix dismissible
- Move isAnimating check to early return in onSlide
- Clean up debug logging
2025-12-19 08:18:56 +08:00
lodev09
6976f172a7
chore: update example components 2025-12-18 03:57:05 +08:00
Jovanni Lo
c88fb1c037
feat(android): improve transition animations and refactor detent calculations (#337)
* feat: update slide animation styles

* fix: move rn-screen observer to preAttached and detached

* feat(android): implement programmatic slide animations for present/dismiss

* refactor(android): cleanup unused animation resources and fix present animation flash

* fix(android): animate footer with sheet during present/dismiss

* refactor(android): sync dim alpha with sheet translation during animations

- Update updateDimAmount() to accept optional sheetTop parameter
- Call updateDimAmount() on each frame during present/dismiss animations
- Remove unused animateDimAlpha() from TrueSheetViewController
- Remove unused animateAlpha() from TrueSheetDimView

* refactor(android): cleanup TrueSheetViewController

- Remove unused imports (Log, ViewCompat)
- Remove unused positionAnimator and setupTransitionTracker
- Use AnimatorListenerAdapter instead of full Animator.AnimatorListener
- Simplify comments and remove debug logs

* fix: move setup methods out of onShowListener

* refactor: make methods consistent

* refactor(android): use alpha + window flags for modal hide/show

- Use alpha fade instead of visibility for hiding sheet during RN Screens modal
- Add FLAG_NOT_TOUCHABLE and FLAG_NOT_FOCUSABLE to prevent interaction when hidden
- Remove unused TrueSheetSlideAnimation style and anim resources

* feat: translate bottomSheetView instead of setupSheetDetents with keyboard

* fix(android): clamp sheet translation during drag to prevent going beyond visible screen

* feat(android): dismiss keyboard when sheet is dragged down to a lower detent

* feat(android): expand to last detent on keyboard show, restore on hide

- Refactor keyboard observer delegate callbacks
- Track pre-keyboard detent and restore on hide
- Skip emitting detent change for keyboard transitions
- Fix 2-detent state map to include STATE_HALF_EXPANDED

* refactor(android): extract TrueSheetDetentCalculator and TrueSheetAnimator

- Extract detent calculations into TrueSheetDetentCalculator class
- Extract present/dismiss animations into TrueSheetAnimator class
- Use interface-based pattern for dynamic prop updates
- Consolidate state variables (InteractionState, KeyboardState)
- Reduce TrueSheetViewController from ~900 to ~650 lines

* refactor(ios): extract TrueSheetDetentCalculator from TrueSheetViewController

- Create TrueSheetDetentCalculator with TrueSheetDetentMeasurements protocol
- Extract detent calculation methods: detentValueForIndex, estimatedPositionForIndex,
  findSegmentForPosition, interpolatedIndexForPosition, interpolatedDetentForPosition
- TrueSheetViewController conforms to protocol for dynamic prop access
- Mirrors Android's interface-based pattern for consistency

* feat(android): skip keyboard handling when sheet is not topmost or hidden by modal

* feat(android): use setupSheetDetents for keyboard handling instead of Y translation

* feat(android): dismiss keyboard when dragged below original position

* chore: run tidy
2025-12-18 00:50:50 +08:00
lodev09
f0ecafca37
docs: add android stacking and dimming blog 2025-12-16 17:58:28 +08:00
Jovanni Lo
c8cc19fc44
fix: batch dismiss behavior for stacked sheets (#322)
* fix(android): dismiss stacked sheets like iOS

* fix(android): fix dismiss animated

* docs: update stacking docs

* feat(example): add names to example sheets

* fix(web): dismiss stacked sheets like iOS
2025-12-14 09:05:50 +08:00
lodev09
e70fc72e2f
fix(ios): prevent parent sheet footer from translating on keyboard show 2025-12-13 19:10:55 +08:00
lodev09
e1ea6b64ac
chore: update PromptSheet example 2025-12-13 08:52:08 +08:00
Jovanni Lo
0c7d983483
feat: improve keyboard handling for Android and iOS (#317)
* fix(android): improve keyboard handling with translationY

* refactor(android): remove keyboardMode prop

* fix(android): cap keyboard translation to screen height

* refactor(android): add TrueSheetKeyboardHandler with API < 30 fallback

* feat(ios): add keyboard handler for footer view
2025-12-13 08:41:05 +08:00
Jovanni Lo
69f0dba353
feat(web): add stackBehavior prop for sheet stacking control (#307)
* chore: tidy clean script

* fix: implement TrueSheetProvider for web

* refactor(example): move TrueSheetProvider to screen level and improve web support

- Move TrueSheetProvider and ReanimatedTrueSheetProvider from root layout to individual screens
- Remove (sheet) folder and rename route to 'sheet'
- Improve web grabber defaults and container layout
- Fix Platform.select to use 'default' instead of 'android' for web compatibility
- Update Input placeholder color and add text color for web visibility
- Add backgroundComponent={null} and fix handle zIndex in web implementation

* feat(web): add stackBehavior prop for sheet stacking control

* docs: simplify Expo Router example with proper types
2025-12-12 07:10:15 +08:00
lodev09
2dec5fc4bc
chore: remove tsconfig from example/shared 2025-12-12 03:29:39 +08:00
Jovanni Lo
4606a1bee9
refactor: reorganize examples with shared package (#306)
* feat(expo-example): update to match example app structure

- Add promise-based present/dismiss to TrueSheet.web.tsx
- Remove tabs navigation, use stack-based routing
- Add screens: Map, Standard, Modal, Test
- Add shared components and sheet components
- Add utils (constants, times, random)
- Add react-native-maps dependency

* feat(expo-example): add Map component and SheetStack with withLayoutContext

- Add platform-specific Map component (native MapView, web View fallback)
- Add sheet-stack route using expo-router's withLayoutContext
- Integrate createTrueSheetNavigator with expo-router file-based routing

* refactor: create shared example-shared package for common components

- Create @truesheet/example-shared workspace package
- Move common components (Button, Header, Footer, etc.) to shared
- Move sheet components (BasicSheet, PromptSheet, etc.) to shared
- Move utils (constants, times, random) to shared
- Update example and expo-example to re-export from shared

* chore: reorganize examples into examples/ folder

- Move example/ to examples/bare/
- Move expo-example/ to examples/expo/
- Move example-shared/ to examples/shared/
- Update workspace paths in root package.json
- Rename packages to @truesheet/bare-example, @truesheet/expo-example
- Update script names (example -> bare, expo)

* chore: update config paths for examples folder reorganization

* chore: rename examples to example and update package names to @example/*

* chore: move screen components to shared package

- Add MapScreen, ModalScreen, StandardScreen, TestScreen to shared
- Make screens navigation-agnostic with callback props
- Add MapComponent prop to MapScreen for platform-specific map
- Create Map component in bare example
- Update expo and bare examples to use shared screens

* chore: import screens directly from @example/shared/screens

* chore: import components and utils directly from @example/shared

* chore: remove unused sheets index files

* chore: move Map component to shared package

* chore: remove unused constants folder from expo example

* chore: remove unused ReanimatedExample component

* chore: update scripts for new example folder structure

* chore: exclude example folder from jest test paths

* chore: add expo prebuild step to clean script

* fix: update config paths for new example folder structure

* chore: categorize steps in clean script

* fix: use workspace:* for example dependencies

- Change @lodev09/react-native-true-sheet from * to workspace:* in bare and expo examples
- Fixes duplicate view registration error caused by npm version being installed alongside workspace
- Silence clean.sh script output while preserving error visibility
2025-12-12 03:08:20 +08:00