@lodev09/react-native-true-sheet 4.0.0-beta.0 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +42 -31
- package/RNTrueSheet.podspec +10 -2
- package/android/build.gradle +2 -1
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +174 -49
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +7 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +371 -18
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +14 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +150 -21
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterViewManager.kt +14 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderView.kt +38 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderViewManager.kt +28 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +84 -24
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +5 -4
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPeekView.kt +72 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetPeekViewManager.kt +33 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetStateUpdater.kt +45 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +526 -231
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +1217 -603
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +136 -29
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensEventObserver.kt +63 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetBehavior.kt +36 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +255 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetCoordinatorLayout.kt +303 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +277 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDimView.kt +162 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +180 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetKeyboardObserver.kt +207 -0
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetStackManager.kt +220 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetDragEvents.kt +71 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetFocusEvents.kt +65 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetLifecycleEvents.kt +112 -0
- package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetStateEvents.kt +56 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/KeyboardUtils.kt +84 -0
- package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +93 -67
- package/android/src/main/java/com/lodev09/truesheet/utils/ViewUtils.kt +30 -0
- package/android/src/main/jni/CMakeLists.txt +63 -0
- package/android/src/main/jni/TrueSheetSpec.h +19 -0
- package/android/src/main/jni/TrueSheetStateUpdater.cpp +96 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewComponentDescriptor.h +24 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.cpp +43 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.h +28 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.cpp +11 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.h +37 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewComponentDescriptor.h +24 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.cpp +56 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.h +28 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.cpp +11 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.h +41 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.cpp +18 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.h +16 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewComponentDescriptor.h +28 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +61 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.h +45 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.cpp +23 -0
- package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.h +52 -0
- package/ios/TrueSheetContainerView.h +81 -6
- package/ios/TrueSheetContainerView.mm +275 -21
- package/ios/TrueSheetContentView.h +38 -1
- package/ios/TrueSheetContentView.mm +413 -43
- package/ios/TrueSheetFooterView.h +27 -2
- package/ios/TrueSheetFooterView.mm +141 -35
- package/ios/{events/OnDidDismissEvent.h → TrueSheetHeaderView.h} +10 -7
- package/ios/TrueSheetHeaderView.mm +64 -0
- package/ios/TrueSheetModule.mm +92 -5
- package/ios/TrueSheetPeekView.h +32 -0
- package/ios/TrueSheetPeekView.mm +99 -0
- package/ios/TrueSheetView.h +7 -15
- package/ios/TrueSheetView.mm +633 -215
- package/ios/TrueSheetViewController.h +84 -16
- package/ios/TrueSheetViewController.mm +1136 -333
- package/ios/core/RNScreensEventObserver.h +46 -0
- package/ios/core/RNScreensEventObserver.mm +280 -0
- package/ios/core/TrueSheetBlurView.h +27 -0
- package/ios/core/TrueSheetBlurView.mm +82 -0
- package/ios/core/TrueSheetDetentCalculator.h +107 -0
- package/ios/core/TrueSheetDetentCalculator.mm +197 -0
- package/ios/core/TrueSheetGrabberView.h +72 -0
- package/ios/core/TrueSheetGrabberView.mm +178 -0
- package/ios/core/TrueSheetKeyboardObserver.h +39 -0
- package/ios/core/TrueSheetKeyboardObserver.mm +112 -0
- package/ios/events/TrueSheetDragEvents.h +39 -0
- package/ios/events/TrueSheetDragEvents.mm +62 -0
- package/ios/events/{OnPositionChangeEvent.h → TrueSheetFocusEvents.h} +8 -5
- package/ios/events/TrueSheetFocusEvents.mm +49 -0
- package/ios/events/TrueSheetLifecycleEvents.h +40 -0
- package/ios/events/TrueSheetLifecycleEvents.mm +71 -0
- package/ios/events/TrueSheetStateEvents.h +35 -0
- package/ios/events/TrueSheetStateEvents.mm +49 -0
- package/ios/tvos/TrueSheetStubs.mm +154 -0
- package/ios/{events/OnMountEvent.h → utils/BlurUtil.h} +5 -7
- package/ios/utils/BlurUtil.mm +69 -0
- package/ios/utils/GestureUtil.h +7 -0
- package/ios/utils/GestureUtil.mm +12 -0
- package/ios/utils/PlatformUtil.h +15 -0
- package/ios/utils/UIView+FirstResponder.h +15 -0
- package/ios/utils/UIView+FirstResponder.mm +26 -0
- package/ios/{events/OnWillDismissEvent.h → utils/UIView+ScrollEdgeInteraction.h} +6 -7
- package/ios/utils/UIView+ScrollEdgeInteraction.mm +62 -0
- package/ios/utils/WindowUtil.mm +17 -1
- package/lib/module/TrueSheet.js +224 -64
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js +1201 -0
- package/lib/module/TrueSheet.web.js.map +1 -0
- package/lib/module/TrueSheetPeek.js +15 -0
- package/lib/module/TrueSheetPeek.js.map +1 -0
- package/lib/module/TrueSheetPeek.web.js +55 -0
- package/lib/module/TrueSheetPeek.web.js.map +1 -0
- package/lib/module/TrueSheetProvider.js +28 -0
- package/lib/module/TrueSheetProvider.js.map +1 -0
- package/lib/module/TrueSheetProvider.web.js +157 -0
- package/lib/module/TrueSheetProvider.web.js.map +1 -0
- package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
- package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +5 -1
- package/lib/module/fabric/TrueSheetFooterViewNativeComponent.ts +10 -2
- package/lib/module/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetPeekViewNativeComponent.ts +8 -0
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +105 -18
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks/index.js +93 -0
- package/lib/module/mocks/index.js.map +1 -0
- package/lib/module/mocks/navigation.js +85 -0
- package/lib/module/mocks/navigation.js.map +1 -0
- package/lib/module/mocks/reanimated.js +91 -0
- package/lib/module/mocks/reanimated.js.map +1 -0
- package/lib/module/navigation/TrueSheetRouter.js +170 -0
- package/lib/module/navigation/TrueSheetRouter.js.map +1 -0
- package/lib/module/navigation/TrueSheetView.js +71 -0
- package/lib/module/navigation/TrueSheetView.js.map +1 -0
- package/lib/module/navigation/createTrueSheetNavigator.js +63 -0
- package/lib/module/navigation/createTrueSheetNavigator.js.map +1 -0
- package/lib/module/navigation/index.js +6 -0
- package/lib/module/navigation/index.js.map +1 -0
- package/lib/module/navigation/screen/ReanimatedTrueSheetScreen.js +56 -0
- package/lib/module/navigation/screen/ReanimatedTrueSheetScreen.js.map +1 -0
- package/lib/module/navigation/screen/TrueSheetScreen.js +49 -0
- package/lib/module/navigation/screen/TrueSheetScreen.js.map +1 -0
- package/lib/module/navigation/screen/index.js +5 -0
- package/lib/module/navigation/screen/index.js.map +1 -0
- package/lib/module/navigation/screen/types.js +4 -0
- package/lib/module/navigation/screen/types.js.map +1 -0
- package/lib/module/navigation/screen/useSheetScreenState.js +68 -0
- package/lib/module/navigation/screen/useSheetScreenState.js.map +1 -0
- package/lib/module/navigation/types.js +4 -0
- package/lib/module/navigation/types.js.map +1 -0
- package/lib/module/navigation/useTrueSheetNavigation.js +24 -0
- package/lib/module/navigation/useTrueSheetNavigation.js.map +1 -0
- package/lib/module/reanimated/ReanimatedTrueSheet.js +15 -9
- package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -1
- package/lib/module/reanimated/ReanimatedTrueSheet.web.js +81 -0
- package/lib/module/reanimated/ReanimatedTrueSheet.web.js.map +1 -0
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +4 -2
- package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
- package/lib/module/reanimated/index.js +2 -2
- package/lib/module/reanimated/index.js.map +1 -1
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js +20 -0
- package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js.map +1 -0
- package/lib/module/specs/NativeTrueSheetModule.js.map +1 -1
- package/lib/module/web/constants.js +16 -0
- package/lib/module/web/constants.js.map +1 -0
- package/lib/module/web/vaul/README.md +9 -0
- package/lib/module/web/vaul/browser.js +30 -0
- package/lib/module/web/vaul/browser.js.map +1 -0
- package/lib/module/web/vaul/constants.js +15 -0
- package/lib/module/web/vaul/constants.js.map +1 -0
- package/lib/module/web/vaul/context.js +59 -0
- package/lib/module/web/vaul/context.js.map +1 -0
- package/lib/module/web/vaul/helpers.js +93 -0
- package/lib/module/web/vaul/helpers.js.map +1 -0
- package/lib/module/web/vaul/index.js +1309 -0
- package/lib/module/web/vaul/index.js.map +1 -0
- package/lib/module/web/vaul/style.css +287 -0
- package/lib/module/web/vaul/style.css.d.js +2 -0
- package/lib/module/web/vaul/style.css.d.js.map +1 -0
- package/lib/module/web/vaul/types.js +2 -0
- package/lib/module/web/vaul/types.js.map +1 -0
- package/lib/module/web/vaul/use-composed-refs.js +34 -0
- package/lib/module/web/vaul/use-composed-refs.js.map +1 -0
- package/lib/module/web/vaul/use-controllable-state.js +54 -0
- package/lib/module/web/vaul/use-controllable-state.js.map +1 -0
- package/lib/module/web/vaul/use-position-fixed.js +123 -0
- package/lib/module/web/vaul/use-position-fixed.js.map +1 -0
- package/lib/module/web/vaul/use-prevent-scroll.js +258 -0
- package/lib/module/web/vaul/use-prevent-scroll.js.map +1 -0
- package/lib/module/web/vaul/use-scale-background.js +57 -0
- package/lib/module/web/vaul/use-scale-background.js.map +1 -0
- package/lib/module/web/vaul/use-snap-points.js +305 -0
- package/lib/module/web/vaul/use-snap-points.js.map +1 -0
- package/lib/typescript/src/TrueSheet.d.ts +51 -14
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +463 -54
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts +5 -0
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetPeek.d.ts +9 -0
- package/lib/typescript/src/TrueSheetPeek.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetPeek.web.d.ts +28 -0
- package/lib/typescript/src/TrueSheetPeek.web.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetProvider.d.ts +18 -0
- package/lib/typescript/src/TrueSheetProvider.d.ts.map +1 -0
- package/lib/typescript/src/TrueSheetProvider.web.d.ts +27 -0
- package/lib/typescript/src/TrueSheetProvider.web.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts +2 -0
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetPeekViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/TrueSheetPeekViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +67 -16
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mocks/index.d.ts +43 -0
- package/lib/typescript/src/mocks/index.d.ts.map +1 -0
- package/lib/typescript/src/mocks/navigation.d.ts +66 -0
- package/lib/typescript/src/mocks/navigation.d.ts.map +1 -0
- package/lib/typescript/src/mocks/reanimated.d.ts +48 -0
- package/lib/typescript/src/mocks/reanimated.d.ts.map +1 -0
- package/lib/typescript/src/navigation/TrueSheetRouter.d.ts +57 -0
- package/lib/typescript/src/navigation/TrueSheetRouter.d.ts.map +1 -0
- package/lib/typescript/src/navigation/TrueSheetView.d.ts +10 -0
- package/lib/typescript/src/navigation/TrueSheetView.d.ts.map +1 -0
- package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts +35 -0
- package/lib/typescript/src/navigation/createTrueSheetNavigator.d.ts.map +1 -0
- package/lib/typescript/src/navigation/index.d.ts +6 -0
- package/lib/typescript/src/navigation/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/ReanimatedTrueSheetScreen.d.ts +3 -0
- package/lib/typescript/src/navigation/screen/ReanimatedTrueSheetScreen.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/TrueSheetScreen.d.ts +3 -0
- package/lib/typescript/src/navigation/screen/TrueSheetScreen.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/index.d.ts +4 -0
- package/lib/typescript/src/navigation/screen/index.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/types.d.ts +15 -0
- package/lib/typescript/src/navigation/screen/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts +35 -0
- package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts.map +1 -0
- package/lib/typescript/src/navigation/types.d.ts +153 -0
- package/lib/typescript/src/navigation/types.d.ts.map +1 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts +23 -0
- package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts +41 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +8 -2
- package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts +15 -0
- package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +25 -3
- package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -1
- package/lib/typescript/src/web/constants.d.ts +14 -0
- package/lib/typescript/src/web/constants.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/browser.d.ts +8 -0
- package/lib/typescript/src/web/vaul/browser.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/constants.d.ts +13 -0
- package/lib/typescript/src/web/vaul/constants.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/context.d.ts +53 -0
- package/lib/typescript/src/web/vaul/context.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/helpers.d.ts +17 -0
- package/lib/typescript/src/web/vaul/helpers.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/index.d.ts +228 -0
- package/lib/typescript/src/web/vaul/index.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/types.d.ts +7 -0
- package/lib/typescript/src/web/vaul/types.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-composed-refs.d.ts +14 -0
- package/lib/typescript/src/web/vaul/use-composed-refs.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-controllable-state.d.ts +9 -0
- package/lib/typescript/src/web/vaul/use-controllable-state.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-position-fixed.d.ts +19 -0
- package/lib/typescript/src/web/vaul/use-position-fixed.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts +18 -0
- package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-scale-background.d.ts +2 -0
- package/lib/typescript/src/web/vaul/use-scale-background.d.ts.map +1 -0
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts +38 -0
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts.map +1 -0
- package/package.json +78 -34
- package/react-native.config.js +9 -2
- package/src/TrueSheet.tsx +276 -60
- package/src/TrueSheet.types.ts +525 -71
- package/src/TrueSheet.web.tsx +1366 -0
- package/src/TrueSheetPeek.tsx +11 -0
- package/src/TrueSheetPeek.web.tsx +63 -0
- package/src/TrueSheetProvider.tsx +33 -0
- package/src/TrueSheetProvider.web.tsx +220 -0
- package/src/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
- package/src/fabric/TrueSheetContentViewNativeComponent.ts +5 -1
- package/src/fabric/TrueSheetFooterViewNativeComponent.ts +10 -2
- package/src/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetPeekViewNativeComponent.ts +8 -0
- package/src/fabric/TrueSheetViewNativeComponent.ts +105 -18
- package/src/index.ts +2 -2
- package/src/mocks/index.ts +89 -0
- package/src/mocks/navigation.ts +72 -0
- package/src/mocks/reanimated.ts +101 -0
- package/src/navigation/TrueSheetRouter.ts +234 -0
- package/src/navigation/TrueSheetView.tsx +99 -0
- package/src/navigation/createTrueSheetNavigator.tsx +93 -0
- package/src/navigation/index.ts +14 -0
- package/src/navigation/screen/ReanimatedTrueSheetScreen.tsx +61 -0
- package/src/navigation/screen/TrueSheetScreen.tsx +54 -0
- package/src/navigation/screen/index.ts +3 -0
- package/src/navigation/screen/types.ts +21 -0
- package/src/navigation/screen/useSheetScreenState.ts +107 -0
- package/src/navigation/types.ts +219 -0
- package/src/navigation/useTrueSheetNavigation.ts +26 -0
- package/src/reanimated/ReanimatedTrueSheet.tsx +12 -7
- package/src/reanimated/ReanimatedTrueSheet.web.tsx +75 -0
- package/src/reanimated/ReanimatedTrueSheetProvider.tsx +12 -8
- package/src/reanimated/useReanimatedPositionChangeHandler.web.ts +31 -0
- package/src/specs/NativeTrueSheetModule.ts +28 -3
- package/src/web/constants.ts +13 -0
- package/src/web/vaul/README.md +9 -0
- package/src/web/vaul/browser.ts +38 -0
- package/src/web/vaul/constants.ts +20 -0
- package/src/web/vaul/context.ts +101 -0
- package/src/web/vaul/helpers.ts +124 -0
- package/src/web/vaul/index.tsx +1740 -0
- package/src/web/vaul/style.css +287 -0
- package/src/web/vaul/style.css.d.ts +1 -0
- package/src/web/vaul/types.ts +7 -0
- package/src/web/vaul/use-composed-refs.ts +35 -0
- package/src/web/vaul/use-controllable-state.ts +66 -0
- package/src/web/vaul/use-position-fixed.ts +147 -0
- package/src/web/vaul/use-prevent-scroll.ts +309 -0
- package/src/web/vaul/use-scale-background.ts +64 -0
- package/src/web/vaul/use-snap-points.ts +455 -0
- package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +0 -26
- package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +0 -32
- package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +0 -27
- package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +0 -20
- package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +0 -26
- package/android/src/main/res/values/styles.xml +0 -8
- package/ios/events/OnDetentChangeEvent.h +0 -28
- package/ios/events/OnDetentChangeEvent.mm +0 -30
- package/ios/events/OnDidDismissEvent.mm +0 -25
- package/ios/events/OnDidPresentEvent.h +0 -28
- package/ios/events/OnDidPresentEvent.mm +0 -30
- package/ios/events/OnDragBeginEvent.h +0 -28
- package/ios/events/OnDragBeginEvent.mm +0 -30
- package/ios/events/OnDragChangeEvent.h +0 -28
- package/ios/events/OnDragChangeEvent.mm +0 -30
- package/ios/events/OnDragEndEvent.h +0 -28
- package/ios/events/OnDragEndEvent.mm +0 -30
- package/ios/events/OnMountEvent.mm +0 -25
- package/ios/events/OnPositionChangeEvent.mm +0 -32
- package/ios/events/OnSizeChangeEvent.h +0 -28
- package/ios/events/OnSizeChangeEvent.mm +0 -30
- package/ios/events/OnWillDismissEvent.mm +0 -25
- package/ios/events/OnWillPresentEvent.h +0 -28
- package/ios/events/OnWillPresentEvent.mm +0 -30
- package/ios/utils/LayoutUtil.h +0 -44
- package/ios/utils/LayoutUtil.mm +0 -50
- package/lib/module/TrueSheetGrabber.js +0 -51
- package/lib/module/TrueSheetGrabber.js.map +0 -1
- package/lib/typescript/src/TrueSheetGrabber.d.ts +0 -39
- package/lib/typescript/src/TrueSheetGrabber.d.ts.map +0 -1
- package/src/TrueSheetGrabber.tsx +0 -82
- package/src/__mocks__/index.js +0 -67
package/src/TrueSheet.tsx
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import type {
|
|
12
12
|
TrueSheetProps,
|
|
13
|
+
TrueSheetMethods,
|
|
14
|
+
TrueSheetStaticMethods,
|
|
13
15
|
DragBeginEvent,
|
|
14
16
|
DragChangeEvent,
|
|
15
17
|
DragEndEvent,
|
|
@@ -20,16 +22,28 @@ import type {
|
|
|
20
22
|
DidDismissEvent,
|
|
21
23
|
WillDismissEvent,
|
|
22
24
|
MountEvent,
|
|
23
|
-
|
|
25
|
+
WillFocusEvent,
|
|
26
|
+
DidFocusEvent,
|
|
27
|
+
WillBlurEvent,
|
|
28
|
+
DidBlurEvent,
|
|
24
29
|
} from './TrueSheet.types';
|
|
25
30
|
import TrueSheetViewNativeComponent from './fabric/TrueSheetViewNativeComponent';
|
|
26
31
|
import TrueSheetContainerViewNativeComponent from './fabric/TrueSheetContainerViewNativeComponent';
|
|
27
32
|
import TrueSheetContentViewNativeComponent from './fabric/TrueSheetContentViewNativeComponent';
|
|
33
|
+
import TrueSheetHeaderViewNativeComponent from './fabric/TrueSheetHeaderViewNativeComponent';
|
|
28
34
|
import TrueSheetFooterViewNativeComponent from './fabric/TrueSheetFooterViewNativeComponent';
|
|
29
35
|
|
|
30
36
|
import TrueSheetModule from './specs/NativeTrueSheetModule';
|
|
31
37
|
|
|
32
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
Platform,
|
|
40
|
+
StyleSheet,
|
|
41
|
+
BackHandler,
|
|
42
|
+
findNodeHandle,
|
|
43
|
+
processColor,
|
|
44
|
+
type NativeEventSubscription,
|
|
45
|
+
type GestureResponderEvent,
|
|
46
|
+
} from 'react-native';
|
|
33
47
|
|
|
34
48
|
const LINKING_ERROR =
|
|
35
49
|
`The package '@lodev09/react-native-true-sheet' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -44,17 +58,31 @@ if (!TrueSheetModule) {
|
|
|
44
58
|
|
|
45
59
|
type NativeRef = ComponentRef<typeof TrueSheetViewNativeComponent>;
|
|
46
60
|
|
|
61
|
+
// Claim touches that no descendant claimed so the responder negotiation
|
|
62
|
+
// doesn't bubble up to touchables outside the sheet
|
|
63
|
+
const absorbUnclaimedTouches = () => true;
|
|
64
|
+
|
|
65
|
+
// Stop raw touch events from bubbling past the sheet to outside ancestors
|
|
66
|
+
const stopTouchPropagation = (event: GestureResponderEvent) => event.stopPropagation();
|
|
67
|
+
|
|
47
68
|
interface TrueSheetState {
|
|
48
69
|
shouldRenderNativeView: boolean;
|
|
49
|
-
containerWidth?: number;
|
|
50
|
-
containerHeight?: number;
|
|
51
70
|
}
|
|
52
71
|
|
|
53
|
-
export class TrueSheet
|
|
72
|
+
export class TrueSheet
|
|
73
|
+
extends PureComponent<TrueSheetProps, TrueSheetState>
|
|
74
|
+
implements TrueSheetMethods
|
|
75
|
+
{
|
|
54
76
|
displayName = 'TrueSheet';
|
|
55
77
|
|
|
56
78
|
private readonly nativeRef: RefObject<NativeRef | null>;
|
|
57
79
|
|
|
80
|
+
private cachedGrabberOptions: TrueSheetProps['grabberOptions'] | undefined;
|
|
81
|
+
private resolvedGrabberOptions: Record<string, unknown> | undefined;
|
|
82
|
+
private backHandlerSubscription: NativeEventSubscription | null = null;
|
|
83
|
+
private isPresented: boolean = false;
|
|
84
|
+
private isSheetVisible: boolean = true;
|
|
85
|
+
|
|
58
86
|
/**
|
|
59
87
|
* Map of sheet names against their instances.
|
|
60
88
|
*/
|
|
@@ -65,6 +93,11 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
65
93
|
*/
|
|
66
94
|
private presentationResolver: (() => void) | null = null;
|
|
67
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Tracks if a present operation is in progress
|
|
98
|
+
*/
|
|
99
|
+
private isPresenting: boolean = false;
|
|
100
|
+
|
|
68
101
|
constructor(props: TrueSheetProps) {
|
|
69
102
|
super(props);
|
|
70
103
|
|
|
@@ -78,8 +111,6 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
78
111
|
|
|
79
112
|
this.state = {
|
|
80
113
|
shouldRenderNativeView: shouldRenderImmediately,
|
|
81
|
-
containerWidth: undefined,
|
|
82
|
-
containerHeight: undefined,
|
|
83
114
|
};
|
|
84
115
|
|
|
85
116
|
this.onMount = this.onMount.bind(this);
|
|
@@ -92,7 +123,12 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
92
123
|
this.onDragChange = this.onDragChange.bind(this);
|
|
93
124
|
this.onDragEnd = this.onDragEnd.bind(this);
|
|
94
125
|
this.onPositionChange = this.onPositionChange.bind(this);
|
|
95
|
-
this.
|
|
126
|
+
this.onWillFocus = this.onWillFocus.bind(this);
|
|
127
|
+
this.onDidFocus = this.onDidFocus.bind(this);
|
|
128
|
+
this.onWillBlur = this.onWillBlur.bind(this);
|
|
129
|
+
this.onDidBlur = this.onDidBlur.bind(this);
|
|
130
|
+
this.handleBackPress = this.handleBackPress.bind(this);
|
|
131
|
+
this.onVisibilityChange = this.onVisibilityChange.bind(this);
|
|
96
132
|
}
|
|
97
133
|
|
|
98
134
|
private validateDetents(): void {
|
|
@@ -108,7 +144,7 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
108
144
|
// Warn for invalid detent fractions
|
|
109
145
|
if (detents) {
|
|
110
146
|
detents.forEach((detent, index) => {
|
|
111
|
-
if (detent
|
|
147
|
+
if (typeof detent === 'number' && detent !== -1 && detent !== -2) {
|
|
112
148
|
if (detent <= 0 || detent > 1) {
|
|
113
149
|
console.warn(
|
|
114
150
|
`TrueSheet: detent at index ${index} (${detent}) should be between 0 and 1. It will be clamped.`
|
|
@@ -152,31 +188,53 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
152
188
|
* Present the sheet by given `name` (Promise-based)
|
|
153
189
|
* @param name - Sheet name (must match sheet's name prop)
|
|
154
190
|
* @param index - Detent index (default: 0)
|
|
191
|
+
* @param animated - Whether to animate the presentation (default: true)
|
|
155
192
|
* @returns Promise that resolves when sheet is fully presented
|
|
156
193
|
* @throws Error if sheet not found or presentation fails
|
|
157
194
|
*/
|
|
158
|
-
public static async present(
|
|
195
|
+
public static async present(
|
|
196
|
+
name: string,
|
|
197
|
+
index: number = 0,
|
|
198
|
+
animated: boolean = true
|
|
199
|
+
): Promise<void> {
|
|
159
200
|
const instance = TrueSheet.getInstance(name);
|
|
160
201
|
if (!instance) {
|
|
161
202
|
throw new Error(`Sheet with name "${name}" not found`);
|
|
162
203
|
}
|
|
163
204
|
|
|
164
|
-
return instance.present(index);
|
|
205
|
+
return instance.present(index, animated);
|
|
165
206
|
}
|
|
166
207
|
|
|
167
208
|
/**
|
|
168
209
|
* Dismiss the sheet by given `name` (Promise-based)
|
|
169
210
|
* @param name - Sheet name
|
|
211
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
170
212
|
* @returns Promise that resolves when sheet is fully dismissed
|
|
171
213
|
* @throws Error if sheet not found or dismissal fails
|
|
172
214
|
*/
|
|
173
|
-
public static async dismiss(name: string): Promise<void> {
|
|
215
|
+
public static async dismiss(name: string, animated: boolean = true): Promise<void> {
|
|
174
216
|
const instance = TrueSheet.getInstance(name);
|
|
175
217
|
if (!instance) {
|
|
176
218
|
throw new Error(`Sheet with name "${name}" not found`);
|
|
177
219
|
}
|
|
178
220
|
|
|
179
|
-
return instance.dismiss();
|
|
221
|
+
return instance.dismiss(animated);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Dismiss only the sheets presented on top of a sheet by given `name`
|
|
226
|
+
* @param name - Sheet name
|
|
227
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
228
|
+
* @returns Promise that resolves when all child sheets are dismissed
|
|
229
|
+
* @throws Error if sheet not found
|
|
230
|
+
*/
|
|
231
|
+
public static async dismissStack(name: string, animated: boolean = true): Promise<void> {
|
|
232
|
+
const instance = TrueSheet.getInstance(name);
|
|
233
|
+
if (!instance) {
|
|
234
|
+
throw new Error(`Sheet with name "${name}" not found`);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return instance.dismissStack(animated);
|
|
180
238
|
}
|
|
181
239
|
|
|
182
240
|
/**
|
|
@@ -195,6 +253,16 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
195
253
|
return instance.resize(index);
|
|
196
254
|
}
|
|
197
255
|
|
|
256
|
+
/**
|
|
257
|
+
* Dismiss all presented sheets by dismissing from the bottom of the stack.
|
|
258
|
+
* This ensures child sheets are dismissed first before their parent.
|
|
259
|
+
* @param animated - Whether to animate the dismissals (default: true)
|
|
260
|
+
* @returns Promise that resolves when all sheets are dismissed
|
|
261
|
+
*/
|
|
262
|
+
public static async dismissAll(animated: boolean = true): Promise<void> {
|
|
263
|
+
return TrueSheetModule?.dismissAll(animated);
|
|
264
|
+
}
|
|
265
|
+
|
|
198
266
|
private registerInstance(): void {
|
|
199
267
|
if (this.props.name) {
|
|
200
268
|
TrueSheet.instances[this.props.name] = this;
|
|
@@ -216,6 +284,16 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
216
284
|
}
|
|
217
285
|
|
|
218
286
|
private onDidPresent(event: DidPresentEvent): void {
|
|
287
|
+
this.isPresented = true;
|
|
288
|
+
|
|
289
|
+
if (Platform.OS === 'android') {
|
|
290
|
+
this.backHandlerSubscription?.remove();
|
|
291
|
+
this.backHandlerSubscription = BackHandler.addEventListener(
|
|
292
|
+
'hardwareBackPress',
|
|
293
|
+
this.handleBackPress
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
219
297
|
this.props.onDidPresent?.(event);
|
|
220
298
|
}
|
|
221
299
|
|
|
@@ -224,8 +302,17 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
224
302
|
}
|
|
225
303
|
|
|
226
304
|
private onDidDismiss(event: DidDismissEvent): void {
|
|
227
|
-
|
|
228
|
-
this.
|
|
305
|
+
this.isPresented = false;
|
|
306
|
+
this.isSheetVisible = true;
|
|
307
|
+
this.backHandlerSubscription?.remove();
|
|
308
|
+
this.backHandlerSubscription = null;
|
|
309
|
+
|
|
310
|
+
// Clean up native view after dismiss for lazy loading.
|
|
311
|
+
// Skip unmount if a present is in progress to avoid race condition.
|
|
312
|
+
if (!this.isPresenting) {
|
|
313
|
+
this.setState({ shouldRenderNativeView: false });
|
|
314
|
+
}
|
|
315
|
+
|
|
229
316
|
this.props.onDidDismiss?.(event);
|
|
230
317
|
}
|
|
231
318
|
|
|
@@ -255,23 +342,50 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
255
342
|
this.props.onPositionChange?.(event);
|
|
256
343
|
}
|
|
257
344
|
|
|
258
|
-
private
|
|
259
|
-
|
|
345
|
+
private onWillFocus(event: WillFocusEvent): void {
|
|
346
|
+
this.props.onWillFocus?.(event);
|
|
347
|
+
}
|
|
260
348
|
|
|
261
|
-
|
|
262
|
-
this.
|
|
263
|
-
|
|
264
|
-
containerHeight: height,
|
|
265
|
-
});
|
|
349
|
+
private onDidFocus(event: DidFocusEvent): void {
|
|
350
|
+
this.props.onDidFocus?.(event);
|
|
351
|
+
}
|
|
266
352
|
|
|
267
|
-
|
|
353
|
+
private onWillBlur(event: WillBlurEvent): void {
|
|
354
|
+
this.props.onWillBlur?.(event);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
private onDidBlur(event: DidBlurEvent): void {
|
|
358
|
+
this.props.onDidBlur?.(event);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
private onVisibilityChange(event: { nativeEvent: { visible: boolean } }): void {
|
|
362
|
+
this.isSheetVisible = event.nativeEvent.visible;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
private handleBackPress(): boolean {
|
|
366
|
+
if (!this.isPresented || !this.isSheetVisible) return false;
|
|
367
|
+
|
|
368
|
+
// The native view can be detached (e.g. host screen unmounted by navigation)
|
|
369
|
+
// before onDidDismiss removes this subscription. Treat back press as a no-op
|
|
370
|
+
// instead of throwing from the handle getter.
|
|
371
|
+
const nodeHandle = findNodeHandle(this.nativeRef.current);
|
|
372
|
+
if (nodeHandle == null || nodeHandle === -1) return false;
|
|
373
|
+
|
|
374
|
+
// When not dismissible, let back propagate (e.g. navigation goes back to the previous screen)
|
|
375
|
+
if (this.props.dismissible === false) {
|
|
376
|
+
return this.props.onBackPress?.() ?? false;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
TrueSheetModule?.handleBackPress(nodeHandle);
|
|
380
|
+
return this.props.onBackPress?.() ?? true;
|
|
268
381
|
}
|
|
269
382
|
|
|
270
383
|
/**
|
|
271
|
-
* Present the
|
|
272
|
-
* @param index -
|
|
384
|
+
* Present the sheet at a given detent index.
|
|
385
|
+
* @param index - The detent index to present at (default: 0)
|
|
386
|
+
* @param animated - Whether to animate the presentation (default: true)
|
|
273
387
|
*/
|
|
274
|
-
public async present(index: number = 0): Promise<void> {
|
|
388
|
+
public async present(index: number = 0, animated: boolean = true): Promise<void> {
|
|
275
389
|
const detentsLength = Math.min(this.props.detents?.length ?? 2, 3); // Max 3 detents
|
|
276
390
|
if (index < 0 || index >= detentsLength) {
|
|
277
391
|
throw new Error(
|
|
@@ -279,6 +393,8 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
279
393
|
);
|
|
280
394
|
}
|
|
281
395
|
|
|
396
|
+
this.isPresenting = true;
|
|
397
|
+
|
|
282
398
|
// Lazy load: render native view if not already rendered
|
|
283
399
|
if (!this.state.shouldRenderNativeView) {
|
|
284
400
|
await new Promise<void>((resolve) => {
|
|
@@ -287,22 +403,33 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
287
403
|
});
|
|
288
404
|
}
|
|
289
405
|
|
|
290
|
-
|
|
406
|
+
await TrueSheetModule?.presentByRef(this.handle, index, animated);
|
|
407
|
+
this.isPresenting = false;
|
|
291
408
|
}
|
|
292
409
|
|
|
293
410
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
411
|
+
* Resize the sheet to a given detent index.
|
|
412
|
+
* @param index - The detent index to resize to
|
|
296
413
|
*/
|
|
297
414
|
public async resize(index: number): Promise<void> {
|
|
298
|
-
await this.
|
|
415
|
+
await TrueSheetModule?.resizeByRef(this.handle, index);
|
|
299
416
|
}
|
|
300
417
|
|
|
301
418
|
/**
|
|
302
|
-
*
|
|
419
|
+
* Dismiss this sheet and all sheets presented on top of it in a single animation.
|
|
420
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
303
421
|
*/
|
|
304
|
-
public async dismiss(): Promise<void> {
|
|
305
|
-
return TrueSheetModule?.dismissByRef(this.handle);
|
|
422
|
+
public async dismiss(animated: boolean = true): Promise<void> {
|
|
423
|
+
return TrueSheetModule?.dismissByRef(this.handle, animated);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Dismiss only the sheets presented on top of this sheet, keeping this sheet presented.
|
|
428
|
+
* If no sheets are presented on top, this method does nothing.
|
|
429
|
+
* @param animated - Whether to animate the dismissal (default: true)
|
|
430
|
+
*/
|
|
431
|
+
public async dismissStack(animated: boolean = true): Promise<void> {
|
|
432
|
+
return TrueSheetModule?.dismissStackByRef(this.handle, animated);
|
|
306
433
|
}
|
|
307
434
|
|
|
308
435
|
componentDidMount(): void {
|
|
@@ -320,35 +447,49 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
320
447
|
|
|
321
448
|
componentWillUnmount(): void {
|
|
322
449
|
this.unregisterInstance();
|
|
323
|
-
|
|
324
|
-
|
|
450
|
+
this.backHandlerSubscription?.remove();
|
|
451
|
+
this.backHandlerSubscription = null;
|
|
325
452
|
this.presentationResolver = null;
|
|
326
453
|
}
|
|
327
454
|
|
|
328
455
|
render(): ReactNode {
|
|
329
456
|
const {
|
|
330
457
|
detents = [0.5, 1],
|
|
331
|
-
backgroundColor
|
|
458
|
+
backgroundColor,
|
|
332
459
|
dismissible = true,
|
|
460
|
+
draggable = true,
|
|
333
461
|
grabber = true,
|
|
462
|
+
grabberOptions,
|
|
463
|
+
accessibilityOptions,
|
|
334
464
|
dimmed = true,
|
|
335
465
|
initialDetentIndex = -1,
|
|
336
466
|
initialDetentAnimated = true,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
467
|
+
dimmedDetentIndex,
|
|
468
|
+
backgroundBlur,
|
|
469
|
+
blurOptions,
|
|
340
470
|
cornerRadius,
|
|
341
|
-
|
|
342
|
-
|
|
471
|
+
maxContentHeight,
|
|
472
|
+
maxContentWidth,
|
|
473
|
+
anchor = 'center',
|
|
474
|
+
anchorOffset,
|
|
475
|
+
scrollableOptions,
|
|
476
|
+
footerOptions,
|
|
477
|
+
presentation = 'page',
|
|
343
478
|
children,
|
|
344
479
|
style,
|
|
480
|
+
header,
|
|
481
|
+
headerStyle,
|
|
482
|
+
headerOptions,
|
|
345
483
|
footer,
|
|
346
|
-
|
|
484
|
+
footerStyle,
|
|
485
|
+
insetAdjustment = 'automatic',
|
|
486
|
+
...rest
|
|
347
487
|
} = this.props;
|
|
348
488
|
|
|
349
489
|
// Trim to max 3 detents and clamp fractions
|
|
350
|
-
const resolvedDetents = detents.slice(0, 3).map((detent) => {
|
|
490
|
+
const resolvedDetents: number[] = detents.slice(0, 3).map((detent) => {
|
|
351
491
|
if (detent === 'auto' || detent === -1) return -1;
|
|
492
|
+
if (detent === 'peek' || detent === -2) return -2;
|
|
352
493
|
|
|
353
494
|
// Default to 0.1 if zero or below
|
|
354
495
|
if (detent <= 0) return 0.1;
|
|
@@ -357,23 +498,46 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
357
498
|
return Math.min(1, detent);
|
|
358
499
|
});
|
|
359
500
|
|
|
501
|
+
// Cache grabberOptions to avoid creating a new object every render
|
|
502
|
+
if (grabberOptions !== this.cachedGrabberOptions) {
|
|
503
|
+
this.cachedGrabberOptions = grabberOptions;
|
|
504
|
+
this.resolvedGrabberOptions = {
|
|
505
|
+
...grabberOptions,
|
|
506
|
+
color: processColor(grabberOptions?.color),
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
|
|
360
510
|
return (
|
|
361
511
|
<TrueSheetViewNativeComponent
|
|
512
|
+
{...rest}
|
|
362
513
|
ref={this.nativeRef}
|
|
363
514
|
style={styles.sheetView}
|
|
364
515
|
detents={resolvedDetents}
|
|
365
|
-
|
|
366
|
-
|
|
516
|
+
backgroundBlur={backgroundBlur}
|
|
517
|
+
blurOptions={blurOptions}
|
|
518
|
+
backgroundColor={backgroundColor}
|
|
367
519
|
cornerRadius={cornerRadius}
|
|
368
520
|
grabber={grabber}
|
|
521
|
+
grabberOptions={this.resolvedGrabberOptions}
|
|
522
|
+
accessibilityOptions={accessibilityOptions}
|
|
369
523
|
dimmed={dimmed}
|
|
370
|
-
|
|
371
|
-
keyboardMode={keyboardMode}
|
|
524
|
+
dimmedDetentIndex={dimmedDetentIndex}
|
|
372
525
|
initialDetentIndex={initialDetentIndex}
|
|
373
526
|
initialDetentAnimated={initialDetentAnimated}
|
|
374
527
|
dismissible={dismissible}
|
|
375
|
-
|
|
376
|
-
|
|
528
|
+
draggable={draggable}
|
|
529
|
+
maxContentHeight={maxContentHeight}
|
|
530
|
+
maxContentWidth={maxContentWidth}
|
|
531
|
+
anchor={anchor}
|
|
532
|
+
anchorOffset={anchorOffset}
|
|
533
|
+
scrollableOptions={scrollableOptions}
|
|
534
|
+
headerOptions={headerOptions}
|
|
535
|
+
footerOptions={{
|
|
536
|
+
footerPosition: footerOptions?.position,
|
|
537
|
+
keyboardOffset: footerOptions?.keyboardOffset,
|
|
538
|
+
}}
|
|
539
|
+
presentation={presentation}
|
|
540
|
+
insetAdjustment={insetAdjustment}
|
|
377
541
|
onMount={this.onMount}
|
|
378
542
|
onWillPresent={this.onWillPresent}
|
|
379
543
|
onDidPresent={this.onDidPresent}
|
|
@@ -384,22 +548,46 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
384
548
|
onDragChange={this.onDragChange}
|
|
385
549
|
onDragEnd={this.onDragEnd}
|
|
386
550
|
onPositionChange={this.onPositionChange}
|
|
387
|
-
|
|
551
|
+
onWillFocus={this.onWillFocus}
|
|
552
|
+
onDidFocus={this.onDidFocus}
|
|
553
|
+
onWillBlur={this.onWillBlur}
|
|
554
|
+
onDidBlur={this.onDidBlur}
|
|
555
|
+
onVisibilityChange={this.onVisibilityChange}
|
|
388
556
|
>
|
|
389
557
|
{this.state.shouldRenderNativeView && (
|
|
390
558
|
<TrueSheetContainerViewNativeComponent
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
559
|
+
style={styles.container}
|
|
560
|
+
onStartShouldSetResponder={absorbUnclaimedTouches}
|
|
561
|
+
onTouchStart={stopTouchPropagation}
|
|
562
|
+
onTouchMove={stopTouchPropagation}
|
|
563
|
+
onTouchEnd={stopTouchPropagation}
|
|
564
|
+
onTouchCancel={stopTouchPropagation}
|
|
397
565
|
>
|
|
398
|
-
|
|
566
|
+
{header && (
|
|
567
|
+
<TrueSheetHeaderViewNativeComponent
|
|
568
|
+
style={[
|
|
569
|
+
styles.header,
|
|
570
|
+
headerOptions?.position === 'absolute' && styles.absoluteHeader,
|
|
571
|
+
headerStyle,
|
|
572
|
+
]}
|
|
573
|
+
>
|
|
574
|
+
{isValidElement(header) ? header : createElement(header)}
|
|
575
|
+
</TrueSheetHeaderViewNativeComponent>
|
|
576
|
+
)}
|
|
577
|
+
<TrueSheetContentViewNativeComponent style={style}>
|
|
399
578
|
{children}
|
|
400
579
|
</TrueSheetContentViewNativeComponent>
|
|
401
580
|
{footer && (
|
|
402
|
-
<TrueSheetFooterViewNativeComponent
|
|
581
|
+
<TrueSheetFooterViewNativeComponent
|
|
582
|
+
autoBottomInset={insetAdjustment === 'automatic'}
|
|
583
|
+
style={[
|
|
584
|
+
styles.footer,
|
|
585
|
+
footerOptions?.position === 'absolute'
|
|
586
|
+
? styles.absoluteFooter
|
|
587
|
+
: styles.relativeFooter,
|
|
588
|
+
footerStyle,
|
|
589
|
+
]}
|
|
590
|
+
>
|
|
403
591
|
{isValidElement(footer) ? footer : createElement(footer)}
|
|
404
592
|
</TrueSheetFooterViewNativeComponent>
|
|
405
593
|
)}
|
|
@@ -410,15 +598,43 @@ export class TrueSheet extends PureComponent<TrueSheetProps, TrueSheetState> {
|
|
|
410
598
|
}
|
|
411
599
|
}
|
|
412
600
|
|
|
601
|
+
// Compile-time check: `TrueSheet`'s static surface must satisfy `TrueSheetStaticMethods`.
|
|
602
|
+
TrueSheet satisfies TrueSheetStaticMethods;
|
|
603
|
+
|
|
413
604
|
const styles = StyleSheet.create({
|
|
414
605
|
sheetView: {
|
|
415
|
-
|
|
416
|
-
width: '100%',
|
|
606
|
+
...StyleSheet.absoluteFill,
|
|
417
607
|
zIndex: -9999,
|
|
608
|
+
pointerEvents: 'box-none',
|
|
609
|
+
},
|
|
610
|
+
// Fill the sheet so flex layouts track the sheet's size per detent
|
|
611
|
+
container: {
|
|
612
|
+
...StyleSheet.absoluteFill,
|
|
613
|
+
},
|
|
614
|
+
header: {
|
|
615
|
+
pointerEvents: 'box-none',
|
|
616
|
+
},
|
|
617
|
+
// Floats over the content so it doesn't take up layout space
|
|
618
|
+
absoluteHeader: {
|
|
619
|
+
position: 'absolute',
|
|
620
|
+
top: 0,
|
|
621
|
+
left: 0,
|
|
622
|
+
right: 0,
|
|
623
|
+
zIndex: 1,
|
|
418
624
|
},
|
|
419
625
|
footer: {
|
|
626
|
+
pointerEvents: 'box-none',
|
|
627
|
+
},
|
|
628
|
+
// Pinned to the sheet's bottom edge via Yoga since the container tracks the
|
|
629
|
+
// sheet's visible height — takes up layout space below the content
|
|
630
|
+
relativeFooter: {
|
|
631
|
+
marginTop: 'auto',
|
|
632
|
+
},
|
|
633
|
+
// Floats over the content so it doesn't take up layout space
|
|
634
|
+
absoluteFooter: {
|
|
420
635
|
position: 'absolute',
|
|
421
636
|
left: 0,
|
|
422
637
|
right: 0,
|
|
638
|
+
bottom: 0,
|
|
423
639
|
},
|
|
424
640
|
});
|