@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
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "TrueSheetDetentCalculator.h"
|
|
10
|
+
|
|
11
|
+
@implementation TrueSheetDetentCalculator {
|
|
12
|
+
NSMutableArray<NSNumber *> *_resolvedDetentOffsets;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
#pragma mark - Public Methods
|
|
16
|
+
|
|
17
|
+
- (CGFloat)detentValueForIndex:(NSInteger)index {
|
|
18
|
+
NSArray<NSNumber *> *detents = self.delegate.detents;
|
|
19
|
+
if (index >= 0 && index < (NSInteger)detents.count) {
|
|
20
|
+
CGFloat value = [detents[index] doubleValue];
|
|
21
|
+
if (value == -1) {
|
|
22
|
+
return [self autoHeight] / self.delegate.screenHeight;
|
|
23
|
+
}
|
|
24
|
+
if (value == -2) {
|
|
25
|
+
return [self peekHeight] / self.delegate.screenHeight;
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (CGFloat)autoHeight {
|
|
33
|
+
// An absolute (floating) header or footer overlaps the content, so it contributes no height
|
|
34
|
+
CGFloat headerHeight = self.delegate.absoluteHeader ? 0 : [self.delegate.headerHeight floatValue];
|
|
35
|
+
CGFloat footerHeight = self.delegate.absoluteFooter ? 0 : [self.delegate.footerHeight floatValue];
|
|
36
|
+
return [self.delegate.contentHeight floatValue] + headerHeight + footerHeight;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (CGFloat)peekHeight {
|
|
40
|
+
// A relative footer is laid out below the content, so it's pushed off-screen
|
|
41
|
+
// at the peek detent and contributes no height
|
|
42
|
+
CGFloat footerHeight = self.delegate.absoluteFooter ? [self.delegate.footerHeight floatValue] : 0;
|
|
43
|
+
CGFloat height =
|
|
44
|
+
[self.delegate.headerHeight floatValue] + footerHeight + [self.delegate.peekContentHeight floatValue];
|
|
45
|
+
return height > 0 ? height : 150;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (void)learnOffsetForDetentIndex:(NSInteger)index {
|
|
49
|
+
if (index < 0 || !_resolvedDetentHeights || index >= (NSInteger)_resolvedDetentHeights.count) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
CGFloat actualHeight = self.delegate.screenHeight - self.delegate.currentPosition;
|
|
54
|
+
CGFloat resolverHeight = [_resolvedDetentHeights[index] doubleValue];
|
|
55
|
+
// Always update — system offset can change between detent transitions
|
|
56
|
+
if (resolverHeight > 0 && actualHeight > 0) {
|
|
57
|
+
_resolvedDetentOffsets[index] = @(actualHeight - resolverHeight);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
- (CGFloat)resolvedHeightForIndex:(NSInteger)index {
|
|
62
|
+
if (_resolvedDetentHeights && index >= 0 && index < (NSInteger)_resolvedDetentHeights.count) {
|
|
63
|
+
CGFloat h = [_resolvedDetentHeights[index] doubleValue];
|
|
64
|
+
if (h > 0) {
|
|
65
|
+
// Use per-detent offset if learned, otherwise find any known offset
|
|
66
|
+
CGFloat offset = [self offsetForIndex:index];
|
|
67
|
+
return h + offset;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
CGFloat detentValue = [self detentValueForIndex:index];
|
|
72
|
+
if (_maxDetentHeight > 0) {
|
|
73
|
+
return detentValue * _maxDetentHeight;
|
|
74
|
+
}
|
|
75
|
+
return detentValue * self.delegate.screenHeight;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
- (CGFloat)offsetForIndex:(NSInteger)index {
|
|
79
|
+
// Use this detent's own offset if available
|
|
80
|
+
if (index >= 0 && index < (NSInteger)_resolvedDetentOffsets.count) {
|
|
81
|
+
CGFloat offset = [_resolvedDetentOffsets[index] doubleValue];
|
|
82
|
+
if (offset != 0)
|
|
83
|
+
return offset;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Fall back to any known offset
|
|
87
|
+
for (NSInteger i = 0; i < (NSInteger)_resolvedDetentOffsets.count; i++) {
|
|
88
|
+
CGFloat offset = [_resolvedDetentOffsets[i] doubleValue];
|
|
89
|
+
if (offset != 0)
|
|
90
|
+
return offset;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
- (BOOL)findSegmentForPosition:(CGFloat)position outIndex:(NSInteger *)outIndex outProgress:(CGFloat *)outProgress {
|
|
97
|
+
NSArray<NSNumber *> *detents = self.delegate.detents;
|
|
98
|
+
NSInteger count = detents.count;
|
|
99
|
+
if (count == 0) {
|
|
100
|
+
*outIndex = -1;
|
|
101
|
+
*outProgress = 0;
|
|
102
|
+
return NO;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
CGFloat screenHeight = self.delegate.screenHeight;
|
|
106
|
+
CGFloat sheetHeight = screenHeight - position;
|
|
107
|
+
CGFloat firstHeight = [self resolvedHeightForIndex:0];
|
|
108
|
+
|
|
109
|
+
// Below first detent - interpolating toward closed
|
|
110
|
+
if (sheetHeight < firstHeight) {
|
|
111
|
+
*outIndex = -1;
|
|
112
|
+
*outProgress = firstHeight > 0 ? (firstHeight - sheetHeight) / firstHeight : 0;
|
|
113
|
+
return NO;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Single detent
|
|
117
|
+
if (count == 1) {
|
|
118
|
+
*outIndex = 0;
|
|
119
|
+
*outProgress = 0;
|
|
120
|
+
return NO;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
CGFloat lastHeight = [self resolvedHeightForIndex:count - 1];
|
|
124
|
+
|
|
125
|
+
// Above last detent
|
|
126
|
+
if (sheetHeight > lastHeight) {
|
|
127
|
+
*outIndex = count - 1;
|
|
128
|
+
*outProgress = 0;
|
|
129
|
+
return NO;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Between detents
|
|
133
|
+
for (NSInteger i = 0; i < count - 1; i++) {
|
|
134
|
+
CGFloat h = [self resolvedHeightForIndex:i];
|
|
135
|
+
CGFloat nextH = [self resolvedHeightForIndex:i + 1];
|
|
136
|
+
|
|
137
|
+
if (sheetHeight >= h && sheetHeight <= nextH) {
|
|
138
|
+
CGFloat range = nextH - h;
|
|
139
|
+
*outIndex = i;
|
|
140
|
+
*outProgress = range > 0 ? (sheetHeight - h) / range : 0;
|
|
141
|
+
return YES;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
*outIndex = count - 1;
|
|
146
|
+
*outProgress = 0;
|
|
147
|
+
return NO;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
- (CGFloat)interpolatedIndexForPosition:(CGFloat)position {
|
|
151
|
+
NSInteger index;
|
|
152
|
+
CGFloat progress;
|
|
153
|
+
BOOL found = [self findSegmentForPosition:position outIndex:&index outProgress:&progress];
|
|
154
|
+
|
|
155
|
+
if (!found) {
|
|
156
|
+
if (index == -1) {
|
|
157
|
+
return -progress;
|
|
158
|
+
}
|
|
159
|
+
return index;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return index + fmax(0, fmin(1, progress));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
- (CGFloat)interpolatedDetentForPosition:(CGFloat)position {
|
|
166
|
+
NSInteger index;
|
|
167
|
+
CGFloat progress;
|
|
168
|
+
BOOL found = [self findSegmentForPosition:position outIndex:&index outProgress:&progress];
|
|
169
|
+
|
|
170
|
+
if (!found) {
|
|
171
|
+
if (index == -1) {
|
|
172
|
+
CGFloat firstDetent = [self detentValueForIndex:0];
|
|
173
|
+
return fmax(0, firstDetent * (1 - progress));
|
|
174
|
+
}
|
|
175
|
+
return [self detentValueForIndex:index];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
CGFloat detent = [self detentValueForIndex:index];
|
|
179
|
+
CGFloat nextDetent = [self detentValueForIndex:index + 1];
|
|
180
|
+
return detent + progress * (nextDetent - detent);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
- (void)clearResolvedHeights {
|
|
184
|
+
[_resolvedDetentHeights removeAllObjects];
|
|
185
|
+
[_resolvedDetentOffsets removeAllObjects];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
- (void)setDetentCount:(NSInteger)count {
|
|
189
|
+
_resolvedDetentHeights = [NSMutableArray arrayWithCapacity:count];
|
|
190
|
+
_resolvedDetentOffsets = [NSMutableArray arrayWithCapacity:count];
|
|
191
|
+
for (NSInteger i = 0; i < count; i++) {
|
|
192
|
+
[_resolvedDetentHeights addObject:@(0)];
|
|
193
|
+
[_resolvedDetentOffsets addObject:@(0)];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <UIKit/UIKit.h>
|
|
10
|
+
#import <react/renderer/components/TrueSheetSpec/Props.h>
|
|
11
|
+
|
|
12
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
13
|
+
|
|
14
|
+
@interface GrabberOptions : NSObject
|
|
15
|
+
|
|
16
|
+
@property (nonatomic, strong, nullable) NSNumber *width;
|
|
17
|
+
@property (nonatomic, strong, nullable) NSNumber *height;
|
|
18
|
+
@property (nonatomic, strong, nullable) NSNumber *topMargin;
|
|
19
|
+
@property (nonatomic, strong, nullable) NSNumber *cornerRadius;
|
|
20
|
+
@property (nonatomic, strong, nullable) UIColor *color;
|
|
21
|
+
@property (nonatomic, assign) BOOL adaptive;
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Native grabber (drag handle) view for the bottom sheet.
|
|
27
|
+
* Uses UIVibrancyEffect to adapt color based on the background.
|
|
28
|
+
*/
|
|
29
|
+
@interface TrueSheetGrabberView : UIView
|
|
30
|
+
|
|
31
|
+
/// Width of the grabber pill (default: 36)
|
|
32
|
+
@property (nonatomic, strong, nullable) NSNumber *grabberWidth;
|
|
33
|
+
|
|
34
|
+
/// Height of the grabber pill (default: 5)
|
|
35
|
+
@property (nonatomic, strong, nullable) NSNumber *grabberHeight;
|
|
36
|
+
|
|
37
|
+
/// Top margin from the sheet edge (default: 5)
|
|
38
|
+
@property (nonatomic, strong, nullable) NSNumber *topMargin;
|
|
39
|
+
|
|
40
|
+
/// Corner radius of the grabber pill (default: height / 2)
|
|
41
|
+
@property (nonatomic, strong, nullable) NSNumber *cornerRadius;
|
|
42
|
+
|
|
43
|
+
/// Custom color for the grabber (uses vibrancy effect when nil)
|
|
44
|
+
@property (nonatomic, strong, nullable) UIColor *color;
|
|
45
|
+
|
|
46
|
+
/// Whether the grabber color adapts to the background (default: YES)
|
|
47
|
+
@property (nonatomic, strong, nullable) NSNumber *adaptive;
|
|
48
|
+
|
|
49
|
+
/// Accessibility strings (defaults come from the codegen prop defaults)
|
|
50
|
+
@property (nonatomic, assign) facebook::react::TrueSheetViewAccessibilityOptionsStruct accessibilityOptions;
|
|
51
|
+
|
|
52
|
+
/// Called when the grabber is tapped
|
|
53
|
+
@property (nonatomic, copy, nullable) void (^onTap)(void);
|
|
54
|
+
|
|
55
|
+
/// Called when VoiceOver user swipes up (expand)
|
|
56
|
+
@property (nonatomic, copy, nullable) void (^onIncrement)(void);
|
|
57
|
+
|
|
58
|
+
/// Called when VoiceOver user swipes down (collapse)
|
|
59
|
+
@property (nonatomic, copy, nullable) void (^onDecrement)(void);
|
|
60
|
+
|
|
61
|
+
/// Adds the grabber view to a parent view with proper constraints
|
|
62
|
+
- (void)addToView:(UIView *)parentView;
|
|
63
|
+
|
|
64
|
+
/// Applies the current configuration to the grabber view
|
|
65
|
+
- (void)applyConfiguration;
|
|
66
|
+
|
|
67
|
+
/// Updates the accessibility value based on the current detent position
|
|
68
|
+
- (void)updateAccessibilityValueWithIndex:(NSInteger)index detentCount:(NSInteger)count;
|
|
69
|
+
|
|
70
|
+
@end
|
|
71
|
+
|
|
72
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "TrueSheetGrabberView.h"
|
|
10
|
+
|
|
11
|
+
#import <React/RCTConversions.h>
|
|
12
|
+
|
|
13
|
+
using namespace facebook::react;
|
|
14
|
+
|
|
15
|
+
@implementation GrabberOptions
|
|
16
|
+
|
|
17
|
+
- (instancetype)init {
|
|
18
|
+
if (self = [super init]) {
|
|
19
|
+
_adaptive = YES;
|
|
20
|
+
}
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
static const CGFloat kDefaultGrabberWidth = 36.0;
|
|
27
|
+
static const CGFloat kDefaultGrabberHeight = 5.0;
|
|
28
|
+
static const CGFloat kDefaultGrabberTopMargin = 5.0;
|
|
29
|
+
static const CGFloat kHitPaddingHorizontal = 20.0;
|
|
30
|
+
static const CGFloat kHitPaddingVertical = 10.0;
|
|
31
|
+
|
|
32
|
+
@implementation TrueSheetGrabberView {
|
|
33
|
+
UIVisualEffectView *_vibrancyView;
|
|
34
|
+
UIView *_fillView;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#pragma mark - Initialization
|
|
38
|
+
|
|
39
|
+
- (instancetype)init {
|
|
40
|
+
if (self = [super init]) {
|
|
41
|
+
[self setupView];
|
|
42
|
+
}
|
|
43
|
+
return self;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#pragma mark - Computed Properties
|
|
47
|
+
|
|
48
|
+
- (CGFloat)effectiveWidth {
|
|
49
|
+
return _grabberWidth ? [_grabberWidth floatValue] : kDefaultGrabberWidth;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (CGFloat)effectiveHeight {
|
|
53
|
+
return _grabberHeight ? [_grabberHeight floatValue] : kDefaultGrabberHeight;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (CGFloat)effectiveTopMargin {
|
|
57
|
+
return _topMargin ? [_topMargin floatValue] : kDefaultGrabberTopMargin;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (CGFloat)effectiveCornerRadius {
|
|
61
|
+
return _cornerRadius ? [_cornerRadius floatValue] : [self effectiveHeight] / 2.0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (BOOL)isAdaptive {
|
|
65
|
+
return _adaptive ? [_adaptive boolValue] : YES;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#pragma mark - Setup
|
|
69
|
+
|
|
70
|
+
- (void)setupView {
|
|
71
|
+
self.clipsToBounds = NO;
|
|
72
|
+
self.isAccessibilityElement = YES;
|
|
73
|
+
self.accessibilityTraits = UIAccessibilityTraitAdjustable | UIAccessibilityTraitButton;
|
|
74
|
+
|
|
75
|
+
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)];
|
|
76
|
+
[self addGestureRecognizer:tap];
|
|
77
|
+
|
|
78
|
+
_vibrancyView = [[UIVisualEffectView alloc] initWithEffect:nil];
|
|
79
|
+
[self addSubview:_vibrancyView];
|
|
80
|
+
|
|
81
|
+
_fillView = [[UIView alloc] init];
|
|
82
|
+
_fillView.backgroundColor = [UIColor.darkGrayColor colorWithAlphaComponent:0.7];
|
|
83
|
+
[_vibrancyView.contentView addSubview:_fillView];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#pragma mark - Actions
|
|
87
|
+
|
|
88
|
+
- (void)handleTap {
|
|
89
|
+
if (_onTap) {
|
|
90
|
+
_onTap();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
- (void)accessibilityIncrement {
|
|
95
|
+
if (_onIncrement) {
|
|
96
|
+
_onIncrement();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)accessibilityDecrement {
|
|
101
|
+
if (_onDecrement) {
|
|
102
|
+
_onDecrement();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#pragma mark - Public
|
|
107
|
+
|
|
108
|
+
- (void)setAccessibilityOptions:(TrueSheetViewAccessibilityOptionsStruct)accessibilityOptions {
|
|
109
|
+
_accessibilityOptions = accessibilityOptions;
|
|
110
|
+
self.accessibilityLabel = RCTNSStringFromStringNilIfEmpty(accessibilityOptions.grabberLabel);
|
|
111
|
+
self.accessibilityHint = RCTNSStringFromStringNilIfEmpty(accessibilityOptions.grabberHint);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
- (void)updateAccessibilityValueWithIndex:(NSInteger)index detentCount:(NSInteger)count {
|
|
115
|
+
if (index < 0 || count <= 0) {
|
|
116
|
+
self.accessibilityValue = nil;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (index >= count - 1) {
|
|
121
|
+
self.accessibilityValue = RCTNSStringFromStringNilIfEmpty(_accessibilityOptions.expandedValue);
|
|
122
|
+
} else if (index == 0) {
|
|
123
|
+
self.accessibilityValue = RCTNSStringFromStringNilIfEmpty(_accessibilityOptions.collapsedValue);
|
|
124
|
+
} else {
|
|
125
|
+
NSString *value = RCTNSStringFromStringNilIfEmpty(_accessibilityOptions.detentValue);
|
|
126
|
+
value = [value stringByReplacingOccurrencesOfString:@"{index}" withString:@(index + 1).stringValue];
|
|
127
|
+
self.accessibilityValue = [value stringByReplacingOccurrencesOfString:@"{count}" withString:@(count).stringValue];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
- (void)addToView:(UIView *)parentView {
|
|
132
|
+
if (self.superview == parentView) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
self.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
|
|
137
|
+
[parentView addSubview:self];
|
|
138
|
+
[self applyConfiguration];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
- (void)applyConfiguration {
|
|
142
|
+
CGFloat pillWidth = [self effectiveWidth];
|
|
143
|
+
CGFloat pillHeight = [self effectiveHeight];
|
|
144
|
+
CGFloat topMargin = [self effectiveTopMargin];
|
|
145
|
+
CGFloat parentWidth = self.superview ? self.superview.bounds.size.width : UIScreen.mainScreen.bounds.size.width;
|
|
146
|
+
|
|
147
|
+
CGFloat frameWidth = pillWidth + kHitPaddingHorizontal * 2;
|
|
148
|
+
CGFloat frameHeight = pillHeight + kHitPaddingVertical * 2;
|
|
149
|
+
CGFloat frameY = topMargin - kHitPaddingVertical;
|
|
150
|
+
|
|
151
|
+
self.frame = CGRectMake((parentWidth - frameWidth) / 2.0, frameY, frameWidth, frameHeight);
|
|
152
|
+
self.backgroundColor = UIColor.clearColor;
|
|
153
|
+
|
|
154
|
+
CGRect pillRect = CGRectMake(kHitPaddingHorizontal, kHitPaddingVertical, pillWidth, pillHeight);
|
|
155
|
+
_vibrancyView.frame = pillRect;
|
|
156
|
+
_vibrancyView.layer.cornerRadius = [self effectiveCornerRadius];
|
|
157
|
+
_vibrancyView.clipsToBounds = YES;
|
|
158
|
+
_fillView.frame = _vibrancyView.contentView.bounds;
|
|
159
|
+
|
|
160
|
+
if (self.isAdaptive) {
|
|
161
|
+
_vibrancyView.effect =
|
|
162
|
+
[UIVibrancyEffect effectForBlurEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemChromeMaterial]
|
|
163
|
+
style:UIVibrancyEffectStyleFill];
|
|
164
|
+
_vibrancyView.backgroundColor = _color;
|
|
165
|
+
_fillView.hidden = NO;
|
|
166
|
+
} else {
|
|
167
|
+
_vibrancyView.effect = nil;
|
|
168
|
+
_fillView.hidden = YES;
|
|
169
|
+
_vibrancyView.backgroundColor = _color ?: [UIColor.darkGrayColor colorWithAlphaComponent:0.7];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
- (void)layoutSubviews {
|
|
174
|
+
[super layoutSubviews];
|
|
175
|
+
[self applyConfiguration];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <UIKit/UIKit.h>
|
|
12
|
+
|
|
13
|
+
@class TrueSheetViewController;
|
|
14
|
+
|
|
15
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
16
|
+
|
|
17
|
+
@protocol TrueSheetKeyboardObserverDelegate <NSObject>
|
|
18
|
+
|
|
19
|
+
- (void)keyboardWillShow:(CGFloat)height duration:(NSTimeInterval)duration curve:(UIViewAnimationOptions)curve;
|
|
20
|
+
- (void)keyboardWillHide:(NSTimeInterval)duration curve:(UIViewAnimationOptions)curve;
|
|
21
|
+
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
@interface TrueSheetKeyboardObserver : NSObject
|
|
25
|
+
|
|
26
|
+
@property (nonatomic, weak, nullable) TrueSheetViewController *viewController;
|
|
27
|
+
@property (nonatomic, readonly) CGFloat currentHeight;
|
|
28
|
+
|
|
29
|
+
- (void)addDelegate:(id<TrueSheetKeyboardObserverDelegate>)delegate;
|
|
30
|
+
- (void)removeDelegate:(id<TrueSheetKeyboardObserverDelegate>)delegate;
|
|
31
|
+
|
|
32
|
+
- (void)start;
|
|
33
|
+
- (void)stop;
|
|
34
|
+
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
NS_ASSUME_NONNULL_END
|
|
38
|
+
|
|
39
|
+
#endif
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import "TrueSheetKeyboardObserver.h"
|
|
12
|
+
#import "../TrueSheetViewController.h"
|
|
13
|
+
#import "../utils/UIView+FirstResponder.h"
|
|
14
|
+
|
|
15
|
+
@implementation TrueSheetKeyboardObserver {
|
|
16
|
+
NSHashTable<id<TrueSheetKeyboardObserverDelegate>> *_delegates;
|
|
17
|
+
CGFloat _currentHeight;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (CGFloat)currentHeight {
|
|
21
|
+
return _currentHeight;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (instancetype)init {
|
|
25
|
+
if (self = [super init]) {
|
|
26
|
+
_delegates = [NSHashTable weakObjectsHashTable];
|
|
27
|
+
}
|
|
28
|
+
return self;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (void)addDelegate:(id<TrueSheetKeyboardObserverDelegate>)delegate {
|
|
32
|
+
[_delegates addObject:delegate];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (void)removeDelegate:(id<TrueSheetKeyboardObserverDelegate>)delegate {
|
|
36
|
+
[_delegates removeObject:delegate];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)start {
|
|
40
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
41
|
+
selector:@selector(keyboardWillChangeFrame:)
|
|
42
|
+
name:UIKeyboardWillChangeFrameNotification
|
|
43
|
+
object:nil];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (void)stop {
|
|
47
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)dealloc {
|
|
51
|
+
[self stop];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (BOOL)isFirstResponderWithinSheet {
|
|
55
|
+
if (!_viewController) {
|
|
56
|
+
return NO;
|
|
57
|
+
}
|
|
58
|
+
UIView *firstResponder = [_viewController.view findFirstResponder];
|
|
59
|
+
return firstResponder != nil;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void)keyboardWillChangeFrame:(NSNotification *)notification {
|
|
63
|
+
if (_viewController && !_viewController.isTopmostPresentedController) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (![self isFirstResponderWithinSheet]) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
NSDictionary *userInfo = notification.userInfo;
|
|
72
|
+
CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
|
73
|
+
NSTimeInterval duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
|
74
|
+
UIViewAnimationOptions curve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue] << 16;
|
|
75
|
+
|
|
76
|
+
UIWindow *window = _viewController.view.window;
|
|
77
|
+
if (!window) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
CGRect keyboardFrameInWindow = [window convertRect:keyboardFrame fromWindow:nil];
|
|
82
|
+
CGFloat keyboardHeight = MAX(0, window.bounds.size.height - keyboardFrameInWindow.origin.y);
|
|
83
|
+
|
|
84
|
+
_currentHeight = keyboardHeight;
|
|
85
|
+
|
|
86
|
+
if (keyboardHeight > 0) {
|
|
87
|
+
_viewController.keyboardSheetGrown = YES;
|
|
88
|
+
} else {
|
|
89
|
+
// The sheet stays grown until UIKit finishes the shrink-back animation —
|
|
90
|
+
// clear after it completes, unless the keyboard came back in the meantime.
|
|
91
|
+
__weak __typeof(self) weakSelf = self;
|
|
92
|
+
dispatch_after(
|
|
93
|
+
dispatch_time(DISPATCH_TIME_NOW, (int64_t)((duration + 0.1) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
94
|
+
__strong __typeof(weakSelf) strongSelf = weakSelf;
|
|
95
|
+
if (strongSelf && strongSelf->_currentHeight == 0) {
|
|
96
|
+
strongSelf->_viewController.keyboardSheetGrown = NO;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
for (id<TrueSheetKeyboardObserverDelegate> delegate in _delegates) {
|
|
102
|
+
if (keyboardHeight > 0) {
|
|
103
|
+
[delegate keyboardWillShow:keyboardHeight duration:duration curve:curve];
|
|
104
|
+
} else {
|
|
105
|
+
[delegate keyboardWillHide:duration curve:curve];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@end
|
|
111
|
+
|
|
112
|
+
#endif
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import <Foundation/Foundation.h>
|
|
12
|
+
#import <react/renderer/components/TrueSheetSpec/EventEmitters.h>
|
|
13
|
+
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
17
|
+
|
|
18
|
+
@interface TrueSheetDragEvents : NSObject
|
|
19
|
+
|
|
20
|
+
+ (void)emitDragBegin:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
21
|
+
index:(NSInteger)index
|
|
22
|
+
position:(CGFloat)position
|
|
23
|
+
detent:(CGFloat)detent;
|
|
24
|
+
|
|
25
|
+
+ (void)emitDragChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
26
|
+
index:(NSInteger)index
|
|
27
|
+
position:(CGFloat)position
|
|
28
|
+
detent:(CGFloat)detent;
|
|
29
|
+
|
|
30
|
+
+ (void)emitDragEnd:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
31
|
+
index:(NSInteger)index
|
|
32
|
+
position:(CGFloat)position
|
|
33
|
+
detent:(CGFloat)detent;
|
|
34
|
+
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
NS_ASSUME_NONNULL_END
|
|
38
|
+
|
|
39
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created by Jovanni Lo (@lodev09)
|
|
3
|
+
// Copyright (c) 2024-present. All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This source code is licensed under the MIT license found in the
|
|
6
|
+
// LICENSE file in the root directory of this source tree.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
10
|
+
|
|
11
|
+
#import "TrueSheetDragEvents.h"
|
|
12
|
+
|
|
13
|
+
@implementation TrueSheetDragEvents
|
|
14
|
+
|
|
15
|
+
+ (void)emitDragBegin:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
16
|
+
index:(NSInteger)index
|
|
17
|
+
position:(CGFloat)position
|
|
18
|
+
detent:(CGFloat)detent {
|
|
19
|
+
if (!eventEmitter)
|
|
20
|
+
return;
|
|
21
|
+
|
|
22
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
23
|
+
TrueSheetViewEventEmitter::OnDragBegin event;
|
|
24
|
+
event.index = static_cast<int>(index);
|
|
25
|
+
event.position = static_cast<double>(position);
|
|
26
|
+
event.detent = static_cast<double>(detent);
|
|
27
|
+
emitter->onDragBegin(event);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
+ (void)emitDragChange:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
31
|
+
index:(NSInteger)index
|
|
32
|
+
position:(CGFloat)position
|
|
33
|
+
detent:(CGFloat)detent {
|
|
34
|
+
if (!eventEmitter)
|
|
35
|
+
return;
|
|
36
|
+
|
|
37
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
38
|
+
TrueSheetViewEventEmitter::OnDragChange event;
|
|
39
|
+
event.index = static_cast<int>(index);
|
|
40
|
+
event.position = static_cast<double>(position);
|
|
41
|
+
event.detent = static_cast<double>(detent);
|
|
42
|
+
emitter->onDragChange(event);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
+ (void)emitDragEnd:(std::shared_ptr<const facebook::react::EventEmitter>)eventEmitter
|
|
46
|
+
index:(NSInteger)index
|
|
47
|
+
position:(CGFloat)position
|
|
48
|
+
detent:(CGFloat)detent {
|
|
49
|
+
if (!eventEmitter)
|
|
50
|
+
return;
|
|
51
|
+
|
|
52
|
+
auto emitter = std::static_pointer_cast<TrueSheetViewEventEmitter const>(eventEmitter);
|
|
53
|
+
TrueSheetViewEventEmitter::OnDragEnd event;
|
|
54
|
+
event.index = static_cast<int>(index);
|
|
55
|
+
event.position = static_cast<double>(position);
|
|
56
|
+
event.detent = static_cast<double>(detent);
|
|
57
|
+
emitter->onDragEnd(event);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@end
|
|
61
|
+
|
|
62
|
+
#endif // RCT_NEW_ARCH_ENABLED
|