Commit Graph

3 Commits

Author SHA1 Message Date
Jovanni Lo
65ac47b738
refactor(cpp): use yoga namespace for StyleSizeLength (#260)
* refactor(cpp): use yoga namespace for StyleSizeLength

- Replace yoga::StyleSizeLength with StyleSizeLength via 'using namespace yoga'
- Switch from <yoga/style/StyleSizeLength.h> to <react/renderer/components/view/conversions.h>
- Aligns with patterns used by react-native-safe-area-context

Ref: https://github.com/lodev09/react-native-true-sheet/discussions/218

* chore: run tidy
2025-12-01 22:28:49 +08:00
Jovanni Lo
248b64de25
feat: move Fabric state wrapper to host view (#230)
* feat: move state wrapper from container view to host view

* fix(ios): call updateStateIfNeeded on every state update

* fix(ios): handle device rotation and only track width changes

* feat(android): align state update flow with iOS

* chore: improve clean script with colors
2025-11-26 03:32:22 +08:00
Jovanni Lo
123afc9e27
feat: handle container layout natively via Fabric state (#220)
* feat(ios): handle container layout natively via Fabric state

- Add custom C++ ShadowNode for TrueSheetContainerView that adjusts Yoga width from native state
- Create TrueSheetContainerViewState with containerWidth field
- Create TrueSheetContainerViewComponentDescriptor that calls adjustLayoutWithState on adopt
- Update TrueSheetContainerView.mm to update state when container bounds change
- Set interfaceOnly: true on TrueSheetContainerViewNativeComponent to use custom ShadowNode
- Remove onSizeChange event and JS-side container dimension handling
- Remove OnSizeChangeEvent files and related delegate methods

This eliminates the JS round-trip for container sizing, improving performance
for sheets rendered as children of other sheets.

* fix(ios): improve safety and code quality

- Add CADisplayLink cleanup in dealloc to prevent retain cycles
- Add array bounds check for detents access
- Add nil check for rootViewController in findPresentingViewController
- Fix float comparison using 0.5 epsilon instead of FLT_EPSILON
- Remove empty dealloc from TrueSheetContainerView
- Remove commented-out code from TrueSheetView.h
- Optimize ConversionUtil with dictionary lookup for O(1) performance

* fix(ios): force layout on mount for correct container width

Trigger layoutIfNeeded when container is mounted to push width to Yoga
before the sheet is presented, preventing visible width changes with
heavy content.

* feat(example): add loading state to ScrollView sheet button

- Add loading prop to Button component
- Increase ScrollViewSheet items to 500 for heavy content testing
- Add loading indicator while presenting ScrollView sheet

* feat(android): implement native container layout sizing

- Add custom C++ ShadowNode and ComponentDescriptor for TrueSheetContainerView
- Push container width from native to Yoga via Fabric State system
- Add StateWrapper handling in TrueSheetContainerView and ViewManager
- Update TrueSheetViewController to call containerView.updateState() on size change
- Remove unused SizeChangeEvent
- Configure CMakeLists.txt and react-native.config.js for custom descriptors

* feat(android): add container height to native layout state

- Add containerHeight alongside containerWidth in TrueSheetContainerViewState
- Update TrueSheetContainerView to track and update both width and height
- Modify TrueSheetContainerViewShadowNode to handle both dimensions
- Add onAttachedToWindow hook for early sizing on Android
- Add debug logging for state updates
- Update ScrollViewSheet example with Android-specific backgroundColor
2025-11-25 10:30:31 +08:00