@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.
- package/android/src/main/java/com/swmansion/reactnativebottomsheet/BottomSheetView.kt +4 -1
- package/ios/BottomSheetContentView.mm +6 -0
- package/ios/RNSBottomSheetHostingView.swift +44 -0
- package/lib/module/BottomSheet.js +101 -38
- package/lib/module/BottomSheet.js.map +1 -1
- package/lib/module/ModalBottomSheet.js +3 -7
- package/lib/module/ModalBottomSheet.js.map +1 -1
- package/lib/module/bottomSheetUtils.js +0 -2
- package/lib/module/bottomSheetUtils.js.map +1 -1
- package/lib/module/index.js +0 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/BottomSheet.d.ts +4 -3
- package/lib/typescript/src/BottomSheet.d.ts.map +1 -1
- package/lib/typescript/src/ModalBottomSheet.d.ts +3 -6
- package/lib/typescript/src/ModalBottomSheet.d.ts.map +1 -1
- package/lib/typescript/src/bottomSheetUtils.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -8
- package/src/BottomSheet.tsx +144 -37
- package/src/ModalBottomSheet.tsx +5 -13
- package/src/bottomSheetUtils.ts +0 -1
- package/src/index.tsx +0 -5
- package/lib/module/BottomSheetBase.js +0 -207
- package/lib/module/BottomSheetBase.js.map +0 -1
- package/lib/module/BottomSheetContext.js +0 -13
- package/lib/module/BottomSheetContext.js.map +0 -1
- package/lib/module/BottomSheetFlatList.js +0 -6
- package/lib/module/BottomSheetFlatList.js.map +0 -1
- package/lib/module/BottomSheetScrollView.js +0 -6
- package/lib/module/BottomSheetScrollView.js.map +0 -1
- package/lib/module/bottomSheetScrollable.js +0 -35
- package/lib/module/bottomSheetScrollable.js.map +0 -1
- package/lib/module/useBottomSheetPanGesture.js +0 -202
- package/lib/module/useBottomSheetPanGesture.js.map +0 -1
- package/lib/module/useBottomSheetScrollable.js +0 -61
- package/lib/module/useBottomSheetScrollable.js.map +0 -1
- package/lib/typescript/src/BottomSheetBase.d.ts +0 -20
- package/lib/typescript/src/BottomSheetBase.d.ts.map +0 -1
- package/lib/typescript/src/BottomSheetContext.d.ts +0 -19
- package/lib/typescript/src/BottomSheetContext.d.ts.map +0 -1
- package/lib/typescript/src/BottomSheetFlatList.d.ts +0 -10
- package/lib/typescript/src/BottomSheetFlatList.d.ts.map +0 -1
- package/lib/typescript/src/BottomSheetScrollView.d.ts +0 -10
- package/lib/typescript/src/BottomSheetScrollView.d.ts.map +0 -1
- package/lib/typescript/src/bottomSheetScrollable.d.ts +0 -9
- package/lib/typescript/src/bottomSheetScrollable.d.ts.map +0 -1
- package/lib/typescript/src/useBottomSheetPanGesture.d.ts +0 -18
- package/lib/typescript/src/useBottomSheetPanGesture.d.ts.map +0 -1
- package/lib/typescript/src/useBottomSheetScrollable.d.ts +0 -13
- package/lib/typescript/src/useBottomSheetScrollable.d.ts.map +0 -1
- package/src/BottomSheetBase.tsx +0 -276
- package/src/BottomSheetContext.tsx +0 -33
- package/src/BottomSheetFlatList.tsx +0 -21
- package/src/BottomSheetScrollView.tsx +0 -22
- package/src/bottomSheetScrollable.tsx +0 -42
- package/src/useBottomSheetPanGesture.ts +0 -253
- 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
|
-
};
|