@swmansion/react-native-bottom-sheet 0.7.0-next.2 → 0.7.0-next.4

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.
Files changed (58) hide show
  1. package/android/src/main/java/com/swmansion/reactnativebottomsheet/BottomSheetView.kt +4 -1
  2. package/ios/BottomSheetContentView.mm +6 -0
  3. package/ios/RNSBottomSheetHostingView.swift +44 -0
  4. package/lib/module/BottomSheet.js +101 -38
  5. package/lib/module/BottomSheet.js.map +1 -1
  6. package/lib/module/ModalBottomSheet.js +3 -7
  7. package/lib/module/ModalBottomSheet.js.map +1 -1
  8. package/lib/module/bottomSheetUtils.js +0 -2
  9. package/lib/module/bottomSheetUtils.js.map +1 -1
  10. package/lib/module/index.js +0 -3
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/typescript/src/BottomSheet.d.ts +4 -3
  13. package/lib/typescript/src/BottomSheet.d.ts.map +1 -1
  14. package/lib/typescript/src/ModalBottomSheet.d.ts +3 -6
  15. package/lib/typescript/src/ModalBottomSheet.d.ts.map +1 -1
  16. package/lib/typescript/src/bottomSheetUtils.d.ts.map +1 -1
  17. package/lib/typescript/src/index.d.ts +0 -5
  18. package/lib/typescript/src/index.d.ts.map +1 -1
  19. package/package.json +2 -8
  20. package/src/BottomSheet.tsx +144 -37
  21. package/src/ModalBottomSheet.tsx +5 -13
  22. package/src/bottomSheetUtils.ts +0 -1
  23. package/src/index.tsx +0 -5
  24. package/lib/module/BottomSheetBase.js +0 -207
  25. package/lib/module/BottomSheetBase.js.map +0 -1
  26. package/lib/module/BottomSheetContext.js +0 -13
  27. package/lib/module/BottomSheetContext.js.map +0 -1
  28. package/lib/module/BottomSheetFlatList.js +0 -6
  29. package/lib/module/BottomSheetFlatList.js.map +0 -1
  30. package/lib/module/BottomSheetScrollView.js +0 -6
  31. package/lib/module/BottomSheetScrollView.js.map +0 -1
  32. package/lib/module/bottomSheetScrollable.js +0 -35
  33. package/lib/module/bottomSheetScrollable.js.map +0 -1
  34. package/lib/module/useBottomSheetPanGesture.js +0 -202
  35. package/lib/module/useBottomSheetPanGesture.js.map +0 -1
  36. package/lib/module/useBottomSheetScrollable.js +0 -61
  37. package/lib/module/useBottomSheetScrollable.js.map +0 -1
  38. package/lib/typescript/src/BottomSheetBase.d.ts +0 -20
  39. package/lib/typescript/src/BottomSheetBase.d.ts.map +0 -1
  40. package/lib/typescript/src/BottomSheetContext.d.ts +0 -19
  41. package/lib/typescript/src/BottomSheetContext.d.ts.map +0 -1
  42. package/lib/typescript/src/BottomSheetFlatList.d.ts +0 -10
  43. package/lib/typescript/src/BottomSheetFlatList.d.ts.map +0 -1
  44. package/lib/typescript/src/BottomSheetScrollView.d.ts +0 -10
  45. package/lib/typescript/src/BottomSheetScrollView.d.ts.map +0 -1
  46. package/lib/typescript/src/bottomSheetScrollable.d.ts +0 -9
  47. package/lib/typescript/src/bottomSheetScrollable.d.ts.map +0 -1
  48. package/lib/typescript/src/useBottomSheetPanGesture.d.ts +0 -18
  49. package/lib/typescript/src/useBottomSheetPanGesture.d.ts.map +0 -1
  50. package/lib/typescript/src/useBottomSheetScrollable.d.ts +0 -13
  51. package/lib/typescript/src/useBottomSheetScrollable.d.ts.map +0 -1
  52. package/src/BottomSheetBase.tsx +0 -276
  53. package/src/BottomSheetContext.tsx +0 -33
  54. package/src/BottomSheetFlatList.tsx +0 -21
  55. package/src/BottomSheetScrollView.tsx +0 -22
  56. package/src/bottomSheetScrollable.tsx +0 -42
  57. package/src/useBottomSheetPanGesture.ts +0 -253
  58. package/src/useBottomSheetScrollable.ts +0 -68
@@ -1,68 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { Gesture } from 'react-native-gesture-handler';
3
- import type { NativeScrollEvent } from 'react-native';
4
- import { isWorkletFunction, scheduleOnRN } from 'react-native-worklets';
5
- import {
6
- type SharedValue,
7
- useAnimatedProps,
8
- useAnimatedRef,
9
- useAnimatedScrollHandler,
10
- useSharedValue,
11
- } from 'react-native-reanimated';
12
-
13
- import { useBottomSheetContext } from './BottomSheetContext';
14
-
15
- type ScrollHandler = (event: NativeScrollEvent) => void;
16
-
17
- export const useBottomSheetScrollable = (
18
- baseScrollEnabled: boolean | SharedValue<boolean | undefined> = true,
19
- onScroll?: ScrollHandler
20
- ) => {
21
- const { isScrollableLocked, registerScrollable, panGesture } =
22
- useBottomSheetContext();
23
- const scrollableRef = useAnimatedRef();
24
- const scrollOffset = useSharedValue(0);
25
- const isGestureActive = useSharedValue(false);
26
- const isWorkletScrollHandler =
27
- onScroll !== undefined ? isWorkletFunction(onScroll) : false;
28
- const scrollHandler = useAnimatedScrollHandler({
29
- onScroll: (event) => {
30
- 'worklet';
31
- scrollOffset.set(Math.max(0, event.contentOffset.y));
32
- if (onScroll === undefined) return;
33
- if (isWorkletScrollHandler) {
34
- onScroll(event);
35
- return;
36
- }
37
- scheduleOnRN(onScroll, event);
38
- },
39
- });
40
- const nativeGesture = Gesture.Native()
41
- .simultaneousWithExternalGesture(panGesture)
42
- .onStart(() => {
43
- 'worklet';
44
- isGestureActive.set(true);
45
- })
46
- .onFinalize(() => {
47
- 'worklet';
48
- isGestureActive.set(false);
49
- });
50
- const animatedProps = useAnimatedProps(() => {
51
- const resolvedScrollEnabled =
52
- (typeof baseScrollEnabled === 'object' && baseScrollEnabled !== null
53
- ? baseScrollEnabled.value
54
- : baseScrollEnabled) ?? true;
55
- return {
56
- scrollEnabled: resolvedScrollEnabled && !isScrollableLocked.value,
57
- };
58
- });
59
- useEffect(() => {
60
- const unregister = registerScrollable({
61
- ref: scrollableRef,
62
- scrollOffset,
63
- isGestureActive,
64
- });
65
- return unregister;
66
- }, [registerScrollable, scrollableRef, scrollOffset, isGestureActive]);
67
- return { scrollHandler, scrollableRef, nativeGesture, animatedProps };
68
- };