@shaquillehinds/react-native-bottom-sheet 0.0.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 +20 -0
- package/README.md +880 -0
- package/lib/commonjs/BottomSheet/animations/drag.animation.js +72 -0
- package/lib/commonjs/BottomSheet/animations/drag.animation.js.map +1 -0
- package/lib/commonjs/BottomSheet/components/BottomSheet.js +92 -0
- package/lib/commonjs/BottomSheet/components/BottomSheet.js.map +1 -0
- package/lib/commonjs/BottomSheet/components/BottomSheetFlatlist.js +38 -0
- package/lib/commonjs/BottomSheet/components/BottomSheetFlatlist.js.map +1 -0
- package/lib/commonjs/BottomSheet/components/BottomSheetModal.js +34 -0
- package/lib/commonjs/BottomSheet/components/BottomSheetModal.js.map +1 -0
- package/lib/commonjs/BottomSheet/components/BottomSheetScrollView.js +37 -0
- package/lib/commonjs/BottomSheet/components/BottomSheetScrollView.js.map +1 -0
- package/lib/commonjs/BottomSheet/config/bottomSheet.constants.js +35 -0
- package/lib/commonjs/BottomSheet/config/bottomSheet.constants.js.map +1 -0
- package/lib/commonjs/BottomSheet/config/bottomSheet.styles.js +42 -0
- package/lib/commonjs/BottomSheet/config/bottomSheet.styles.js.map +1 -0
- package/lib/commonjs/BottomSheet/config/bottomSheet.types.js +14 -0
- package/lib/commonjs/BottomSheet/config/bottomSheet.types.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/bottomFlatlist.controller.js +69 -0
- package/lib/commonjs/BottomSheet/controller/bottomFlatlist.controller.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/bottomScrollView.controller.js +41 -0
- package/lib/commonjs/BottomSheet/controller/bottomScrollView.controller.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/bottomSheet.controller.js +216 -0
- package/lib/commonjs/BottomSheet/controller/bottomSheet.controller.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/callbacks.controller.js +135 -0
- package/lib/commonjs/BottomSheet/controller/callbacks.controller.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/dragAnimation.controller.js +127 -0
- package/lib/commonjs/BottomSheet/controller/dragAnimation.controller.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetRef.js +60 -0
- package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetRef.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetUtils.js +74 -0
- package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetUtils.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/index.js +17 -0
- package/lib/commonjs/BottomSheet/controller/index.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/keyboardAnimation.controller.js +88 -0
- package/lib/commonjs/BottomSheet/controller/keyboardAnimation.controller.js.map +1 -0
- package/lib/commonjs/BottomSheet/controller/scrollContent.controller.js +89 -0
- package/lib/commonjs/BottomSheet/controller/scrollContent.controller.js.map +1 -0
- package/lib/commonjs/BottomSheet/index.js +130 -0
- package/lib/commonjs/BottomSheet/index.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/BottomSheet/animations/drag.animation.js +68 -0
- package/lib/module/BottomSheet/animations/drag.animation.js.map +1 -0
- package/lib/module/BottomSheet/components/BottomSheet.js +87 -0
- package/lib/module/BottomSheet/components/BottomSheet.js.map +1 -0
- package/lib/module/BottomSheet/components/BottomSheetFlatlist.js +32 -0
- package/lib/module/BottomSheet/components/BottomSheetFlatlist.js.map +1 -0
- package/lib/module/BottomSheet/components/BottomSheetModal.js +30 -0
- package/lib/module/BottomSheet/components/BottomSheetModal.js.map +1 -0
- package/lib/module/BottomSheet/components/BottomSheetScrollView.js +31 -0
- package/lib/module/BottomSheet/components/BottomSheetScrollView.js.map +1 -0
- package/lib/module/BottomSheet/config/bottomSheet.constants.js +30 -0
- package/lib/module/BottomSheet/config/bottomSheet.constants.js.map +1 -0
- package/lib/module/BottomSheet/config/bottomSheet.styles.js +38 -0
- package/lib/module/BottomSheet/config/bottomSheet.styles.js.map +1 -0
- package/lib/module/BottomSheet/config/bottomSheet.types.js +10 -0
- package/lib/module/BottomSheet/config/bottomSheet.types.js.map +1 -0
- package/lib/module/BottomSheet/controller/bottomFlatlist.controller.js +64 -0
- package/lib/module/BottomSheet/controller/bottomFlatlist.controller.js.map +1 -0
- package/lib/module/BottomSheet/controller/bottomScrollView.controller.js +37 -0
- package/lib/module/BottomSheet/controller/bottomScrollView.controller.js.map +1 -0
- package/lib/module/BottomSheet/controller/bottomSheet.controller.js +212 -0
- package/lib/module/BottomSheet/controller/bottomSheet.controller.js.map +1 -0
- package/lib/module/BottomSheet/controller/callbacks.controller.js +130 -0
- package/lib/module/BottomSheet/controller/callbacks.controller.js.map +1 -0
- package/lib/module/BottomSheet/controller/dragAnimation.controller.js +122 -0
- package/lib/module/BottomSheet/controller/dragAnimation.controller.js.map +1 -0
- package/lib/module/BottomSheet/controller/hooks/useBottomSheetRef.js +56 -0
- package/lib/module/BottomSheet/controller/hooks/useBottomSheetRef.js.map +1 -0
- package/lib/module/BottomSheet/controller/hooks/useBottomSheetUtils.js +70 -0
- package/lib/module/BottomSheet/controller/hooks/useBottomSheetUtils.js.map +1 -0
- package/lib/module/BottomSheet/controller/index.js +4 -0
- package/lib/module/BottomSheet/controller/index.js.map +1 -0
- package/lib/module/BottomSheet/controller/keyboardAnimation.controller.js +84 -0
- package/lib/module/BottomSheet/controller/keyboardAnimation.controller.js.map +1 -0
- package/lib/module/BottomSheet/controller/scrollContent.controller.js +84 -0
- package/lib/module/BottomSheet/controller/scrollContent.controller.js.map +1 -0
- package/lib/module/BottomSheet/index.js +112 -0
- package/lib/module/BottomSheet/index.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/animations/drag.animation.d.ts +31 -0
- package/lib/typescript/commonjs/src/BottomSheet/animations/drag.animation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheet.d.ts +9 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetFlatlist.d.ts +3 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetFlatlist.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetModal.d.ts +8 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetScrollView.d.ts +3 -0
- package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetScrollView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.constants.d.ts +30 -0
- package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.styles.d.ts +37 -0
- package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.styles.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.types.d.ts +185 -0
- package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/bottomFlatlist.controller.d.ts +480 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/bottomFlatlist.controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/bottomScrollView.controller.d.ts +338 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/bottomScrollView.controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/bottomSheet.controller.d.ts +51 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/bottomSheet.controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/callbacks.controller.d.ts +36 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/callbacks.controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/dragAnimation.controller.d.ts +27 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/dragAnimation.controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts +12 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts +40 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/keyboardAnimation.controller.d.ts +15 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/keyboardAnimation.controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/scrollContent.controller.d.ts +20 -0
- package/lib/typescript/commonjs/src/BottomSheet/controller/scrollContent.controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BottomSheet/index.d.ts +23 -0
- package/lib/typescript/commonjs/src/BottomSheet/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/BottomSheet/animations/drag.animation.d.ts +31 -0
- package/lib/typescript/module/src/BottomSheet/animations/drag.animation.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheet.d.ts +9 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheetFlatlist.d.ts +3 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheetFlatlist.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheetModal.d.ts +8 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheetModal.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheetScrollView.d.ts +3 -0
- package/lib/typescript/module/src/BottomSheet/components/BottomSheetScrollView.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/config/bottomSheet.constants.d.ts +30 -0
- package/lib/typescript/module/src/BottomSheet/config/bottomSheet.constants.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/config/bottomSheet.styles.d.ts +37 -0
- package/lib/typescript/module/src/BottomSheet/config/bottomSheet.styles.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/config/bottomSheet.types.d.ts +185 -0
- package/lib/typescript/module/src/BottomSheet/config/bottomSheet.types.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/bottomFlatlist.controller.d.ts +480 -0
- package/lib/typescript/module/src/BottomSheet/controller/bottomFlatlist.controller.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/bottomScrollView.controller.d.ts +338 -0
- package/lib/typescript/module/src/BottomSheet/controller/bottomScrollView.controller.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/bottomSheet.controller.d.ts +51 -0
- package/lib/typescript/module/src/BottomSheet/controller/bottomSheet.controller.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/callbacks.controller.d.ts +36 -0
- package/lib/typescript/module/src/BottomSheet/controller/callbacks.controller.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/dragAnimation.controller.d.ts +27 -0
- package/lib/typescript/module/src/BottomSheet/controller/dragAnimation.controller.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts +12 -0
- package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts +40 -0
- package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/index.d.ts +2 -0
- package/lib/typescript/module/src/BottomSheet/controller/index.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/keyboardAnimation.controller.d.ts +15 -0
- package/lib/typescript/module/src/BottomSheet/controller/keyboardAnimation.controller.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/controller/scrollContent.controller.d.ts +20 -0
- package/lib/typescript/module/src/BottomSheet/controller/scrollContent.controller.d.ts.map +1 -0
- package/lib/typescript/module/src/BottomSheet/index.d.ts +23 -0
- package/lib/typescript/module/src/BottomSheet/index.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +2 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +203 -0
- package/src/BottomSheet/animations/drag.animation.ts +86 -0
- package/src/BottomSheet/components/BottomSheet.tsx +157 -0
- package/src/BottomSheet/components/BottomSheetFlatlist.tsx +46 -0
- package/src/BottomSheet/components/BottomSheetModal.tsx +47 -0
- package/src/BottomSheet/components/BottomSheetScrollView.tsx +46 -0
- package/src/BottomSheet/config/bottomSheet.constants.ts +31 -0
- package/src/BottomSheet/config/bottomSheet.styles.ts +42 -0
- package/src/BottomSheet/config/bottomSheet.types.ts +246 -0
- package/src/BottomSheet/controller/bottomFlatlist.controller.ts +87 -0
- package/src/BottomSheet/controller/bottomScrollView.controller.ts +43 -0
- package/src/BottomSheet/controller/bottomSheet.controller.ts +238 -0
- package/src/BottomSheet/controller/callbacks.controller.ts +222 -0
- package/src/BottomSheet/controller/dragAnimation.controller.ts +211 -0
- package/src/BottomSheet/controller/hooks/useBottomSheetRef.ts +73 -0
- package/src/BottomSheet/controller/hooks/useBottomSheetUtils.ts +75 -0
- package/src/BottomSheet/controller/index.ts +1 -0
- package/src/BottomSheet/controller/keyboardAnimation.controller.ts +148 -0
- package/src/BottomSheet/controller/scrollContent.controller.ts +120 -0
- package/src/BottomSheet/index.tsx +139 -0
- package/src/index.tsx +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isIOS, relativeY } from '@shaquillehinds/react-native-essentials';
|
|
2
|
+
import { Easing } from 'react-native-reanimated';
|
|
3
|
+
|
|
4
|
+
export const extraHeightPercent = 10;
|
|
5
|
+
export const extraHeight = relativeY(extraHeightPercent);
|
|
6
|
+
export const modalHeight = relativeY(100) + extraHeight;
|
|
7
|
+
export const modalContentMaxHeight = modalHeight;
|
|
8
|
+
|
|
9
|
+
// Needed for bottomModal.styles
|
|
10
|
+
export const modalBottomOffset = -modalHeight * 2;
|
|
11
|
+
|
|
12
|
+
export const modalTimingConfig = (duration = 500) => ({
|
|
13
|
+
duration,
|
|
14
|
+
easing: Easing.bezier(0.2, 0.32, 0, 1),
|
|
15
|
+
});
|
|
16
|
+
export const modalTransitionTimingConfig = modalTimingConfig();
|
|
17
|
+
export const animateOpenTimingConfig = modalTimingConfig();
|
|
18
|
+
|
|
19
|
+
export const animateCloseTimingConfig = {
|
|
20
|
+
duration: 300,
|
|
21
|
+
easing: Easing.linear,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const openKeyboardTimingConfig = {
|
|
25
|
+
duration: isIOS ? 330 : 500,
|
|
26
|
+
easing: isIOS ? Easing.bezier(0, 0.7, 0, 1) : Easing.bezier(0, 0.2, 0, 1),
|
|
27
|
+
};
|
|
28
|
+
export const closeKeyboardTimingConfig = {
|
|
29
|
+
duration: isIOS ? 450 : 500,
|
|
30
|
+
easing: Easing.bezier(0, 0.2, 0, 1),
|
|
31
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { modalBottomOffset, modalHeight } from './bottomSheet.constants';
|
|
3
|
+
import {
|
|
4
|
+
relativeShort,
|
|
5
|
+
relativeX,
|
|
6
|
+
relativeY,
|
|
7
|
+
maxZIndex,
|
|
8
|
+
} from '@shaquillehinds/react-native-essentials';
|
|
9
|
+
|
|
10
|
+
export const bottomModalStyle = StyleSheet.create({
|
|
11
|
+
bottomSheet: {
|
|
12
|
+
backgroundColor: 'white',
|
|
13
|
+
width: relativeX(100),
|
|
14
|
+
height: modalHeight,
|
|
15
|
+
borderRadius: relativeShort(7),
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
bottom: modalBottomOffset,
|
|
18
|
+
zIndex: maxZIndex,
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
},
|
|
21
|
+
contentContainer: {
|
|
22
|
+
paddingBottom: relativeY(10),
|
|
23
|
+
},
|
|
24
|
+
bumper: {
|
|
25
|
+
backgroundColor: 'rgba(156,170,180,0.3)',
|
|
26
|
+
width: relativeX(15),
|
|
27
|
+
borderRadius: 5,
|
|
28
|
+
height: relativeY(0.2),
|
|
29
|
+
alignSelf: 'center',
|
|
30
|
+
marginVertical: relativeY(1.4),
|
|
31
|
+
},
|
|
32
|
+
bumperContainer: {
|
|
33
|
+
zIndex: maxZIndex + 5,
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
background: {
|
|
37
|
+
...StyleSheet.absoluteFillObject,
|
|
38
|
+
zIndex: maxZIndex,
|
|
39
|
+
backgroundColor: 'rgba(0,0,0,.1)',
|
|
40
|
+
opacity: 1,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
FlatList,
|
|
4
|
+
NativeScrollEvent,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
StyleProp,
|
|
7
|
+
TextInput,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import type {
|
|
11
|
+
AnimatedScrollViewProps,
|
|
12
|
+
EasingFunction,
|
|
13
|
+
EasingFunctionFactory,
|
|
14
|
+
FlatListPropsWithLayout,
|
|
15
|
+
SharedValue,
|
|
16
|
+
} from 'react-native-reanimated';
|
|
17
|
+
import type {
|
|
18
|
+
GestureStateChangeEvent,
|
|
19
|
+
GestureUpdateEvent,
|
|
20
|
+
PanGestureHandlerEventPayload,
|
|
21
|
+
} from 'react-native-gesture-handler';
|
|
22
|
+
import type { ReanimatedScrollEvent } from 'react-native-reanimated/lib/typescript/hook/commonTypes';
|
|
23
|
+
import type { AnimatedScrollView } from 'react-native-reanimated/lib/typescript/component/ScrollView';
|
|
24
|
+
import type {
|
|
25
|
+
PortalContextValue,
|
|
26
|
+
ModalWrapperProps,
|
|
27
|
+
} from '@shaquillehinds/react-native-essentials';
|
|
28
|
+
|
|
29
|
+
export type BottomSheetProps = {
|
|
30
|
+
showModal?: boolean;
|
|
31
|
+
setShowModal?:
|
|
32
|
+
| React.Dispatch<React.SetStateAction<boolean>>
|
|
33
|
+
| ((bool: boolean) => void);
|
|
34
|
+
|
|
35
|
+
_unMounter?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Modal snaps to various positions of the screens overall height.
|
|
38
|
+
* Takes a percentage of the screen height.
|
|
39
|
+
* @example
|
|
40
|
+
* [25, "50", "75%"]
|
|
41
|
+
*/
|
|
42
|
+
snapPoints?: (number | string)[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Defines which part of the modal is draggable.
|
|
46
|
+
* "Full" makes the entire modal draggable.
|
|
47
|
+
* @default "bumper"
|
|
48
|
+
*/
|
|
49
|
+
dragArea?: 'full' | 'bumper' | 'none';
|
|
50
|
+
/**
|
|
51
|
+
* Prevents full unmounting. Use with bottomOffset if you want to see the modal when it's "closed".
|
|
52
|
+
*/
|
|
53
|
+
keepMounted?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Removes the top part of the modal that is draggable.
|
|
56
|
+
*/
|
|
57
|
+
hideBumper?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Adds content bottom padding when the keyboard is visible. Use inputsForKeyboardToAvoid if you only want the padding to be adding when certain inputs are focused.
|
|
60
|
+
*/
|
|
61
|
+
avoidKeyboard?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* By default the modal isn't draggable when the keyboard is visible to prevent weird behavior when avoidKeyboard is active.
|
|
64
|
+
* Add this prop to disable that behavior.
|
|
65
|
+
*/
|
|
66
|
+
allowDragWhileKeyboardVisible?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Function to run when the modal is mounting.
|
|
69
|
+
*/
|
|
70
|
+
onModalShow?: () => Promise<void> | void;
|
|
71
|
+
/**
|
|
72
|
+
* Function to run when the modal is unmounting.
|
|
73
|
+
*/
|
|
74
|
+
onModalClose?: () => Promise<void> | void;
|
|
75
|
+
/**
|
|
76
|
+
* Function to run when modal reaches a snapPoint
|
|
77
|
+
*/
|
|
78
|
+
onSnapPointReach?: (snapPointIndex: number) => Promise<void> | void;
|
|
79
|
+
/**
|
|
80
|
+
* Style for the modal sheet itself, not the modal content.
|
|
81
|
+
*/
|
|
82
|
+
style?: StyleProp<ViewStyle>;
|
|
83
|
+
/**
|
|
84
|
+
* Style for the bumper itself, not it's container.
|
|
85
|
+
*/
|
|
86
|
+
bumperStyle?: StyleProp<ViewStyle>;
|
|
87
|
+
/**
|
|
88
|
+
* Style for the bumper container, not the actual bumper.
|
|
89
|
+
*/
|
|
90
|
+
bumperContainerStyle?: StyleProp<ViewStyle>;
|
|
91
|
+
/**
|
|
92
|
+
* Sets the background color of the modal and the bumper container.
|
|
93
|
+
*/
|
|
94
|
+
backgroundColor?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Style for the modal content container, not the modal sheet itself.
|
|
97
|
+
*/
|
|
98
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
99
|
+
/**
|
|
100
|
+
* Provide a custom bumper component that replaces the default one. This component will be draggrable.
|
|
101
|
+
*/
|
|
102
|
+
BumperComponent?: () => React.ReactNode;
|
|
103
|
+
/**
|
|
104
|
+
* Adds content bottom padding for the modal depending on if the provided inputRef is focused.
|
|
105
|
+
*/
|
|
106
|
+
inputsForKeyboardToAvoid?: React.RefObject<TextInput>[];
|
|
107
|
+
/**
|
|
108
|
+
* Pushes the modal up. Useful when used with keepMounted prop and you want to still the modal in it's closed position.
|
|
109
|
+
*/
|
|
110
|
+
bottomOffset?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Delay as to when content should be shown.
|
|
113
|
+
* Use 'mount' type for heavy loaded content that causes sluggish modal entry to improve performance.
|
|
114
|
+
* Give the contentContainerStyle prop an appropriate minHeight or height when using type 'mount'.
|
|
115
|
+
*/
|
|
116
|
+
showContentDelay?: {
|
|
117
|
+
/**
|
|
118
|
+
* @default - "opacity"
|
|
119
|
+
*/
|
|
120
|
+
type?: 'mount' | 'opacity';
|
|
121
|
+
timeInMilliSecs: number;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Disables the use use of the portabl provider to render component
|
|
126
|
+
*/
|
|
127
|
+
disablePortal?: boolean;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Provide a custom context in case you want to restrict your modal to particular portal
|
|
131
|
+
*/
|
|
132
|
+
CustomPortalContext?: React.Context<PortalContextValue | undefined>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type BottomSheetModalProps = {
|
|
136
|
+
/**
|
|
137
|
+
* Custom backdrop component instead of the default blurview
|
|
138
|
+
*/
|
|
139
|
+
BackdropComponent?: React.ReactNode;
|
|
140
|
+
onBackDropPress?: () => void;
|
|
141
|
+
disableCloseOnBackdropPress?: boolean;
|
|
142
|
+
} & BottomSheetProps &
|
|
143
|
+
ModalWrapperProps;
|
|
144
|
+
|
|
145
|
+
export type BottomSheetContextProps = {
|
|
146
|
+
scrollY: SharedValue<number>;
|
|
147
|
+
maxScrollOffset: SharedValue<number>;
|
|
148
|
+
inverted: SharedValue<boolean>;
|
|
149
|
+
onBeginScroll: (
|
|
150
|
+
e: GestureStateChangeEvent<PanGestureHandlerEventPayload>
|
|
151
|
+
) => void;
|
|
152
|
+
onUpdateScroll: (
|
|
153
|
+
e: GestureUpdateEvent<PanGestureHandlerEventPayload>
|
|
154
|
+
) => void;
|
|
155
|
+
onEndScroll: (
|
|
156
|
+
e: GestureStateChangeEvent<PanGestureHandlerEventPayload>
|
|
157
|
+
) => void;
|
|
158
|
+
scrollableComponentRef: ScrollComponentRef;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export type BottomModalContextProps = {
|
|
162
|
+
modalRef: BottomModalRef;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type BottomSheetFlatlistProps<T> = Omit<
|
|
166
|
+
FlatListPropsWithLayout<T>,
|
|
167
|
+
'onScroll'
|
|
168
|
+
> & {
|
|
169
|
+
onScroll?: ReanimatedOnScroll | DefaultOnScroll;
|
|
170
|
+
refFlatlist?: React.MutableRefObject<FlatList> | React.RefObject<FlatList>;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export type BottomSheetScrollViewProps = Omit<
|
|
174
|
+
AnimatedScrollViewProps,
|
|
175
|
+
'onScroll'
|
|
176
|
+
> & {
|
|
177
|
+
onScroll?: ReanimatedOnScroll | DefaultOnScroll;
|
|
178
|
+
refScrollView?:
|
|
179
|
+
| React.MutableRefObject<AnimatedScrollView>
|
|
180
|
+
| React.RefObject<AnimatedScrollView>;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export type DefaultOnScroll = (
|
|
184
|
+
event: NativeSyntheticEvent<NativeScrollEvent>
|
|
185
|
+
) => void;
|
|
186
|
+
export type ReanimatedOnScroll = (event: ReanimatedScrollEvent) => void;
|
|
187
|
+
|
|
188
|
+
export type ScrollComponentRef =
|
|
189
|
+
React.MutableRefObject<ScrollComponentRefProps>;
|
|
190
|
+
|
|
191
|
+
export type ScrollComponentRefProps = FlatList | AnimatedScrollView | null;
|
|
192
|
+
|
|
193
|
+
export enum ModalState {
|
|
194
|
+
CLOSED = 0,
|
|
195
|
+
OPENING = 1,
|
|
196
|
+
OPEN = 2,
|
|
197
|
+
CLOSING = 3,
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export type SnapPoint = {
|
|
201
|
+
offset: number;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
type SnapController = {
|
|
205
|
+
snapToIndex: (snapPointIndex: number) => void;
|
|
206
|
+
snapToPercentage: (percentage: number | string) => void;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export type AnimateCloseModalProps = {
|
|
210
|
+
duration?: number;
|
|
211
|
+
easing?: EasingFunction | EasingFunctionFactory;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export type BottomSheetRef = {
|
|
215
|
+
getModalState: () => ModalState;
|
|
216
|
+
animateCloseModal: (props?: AnimateCloseModalProps) => void;
|
|
217
|
+
} & SnapController;
|
|
218
|
+
|
|
219
|
+
export type BottomSheetRefObject = React.Ref<BottomSheetRef>;
|
|
220
|
+
|
|
221
|
+
export type CloseModalProps = {
|
|
222
|
+
/**
|
|
223
|
+
* Instantly unmounts modal without animation.
|
|
224
|
+
* Useful for glitchy android navigation.
|
|
225
|
+
*/
|
|
226
|
+
skipAnimation?: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Reduces animation duration to 100ms
|
|
229
|
+
* Useful for glitchy android navigation.
|
|
230
|
+
*/
|
|
231
|
+
isNavigating?: boolean;
|
|
232
|
+
onClose?: () => void;
|
|
233
|
+
} & AnimateCloseModalProps;
|
|
234
|
+
|
|
235
|
+
export type OpenModalProps = {
|
|
236
|
+
onOpen?: () => void;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export type BottomModalRef = {
|
|
240
|
+
getModalState: () => ModalState | undefined;
|
|
241
|
+
openModal: (props?: OpenModalProps) => void;
|
|
242
|
+
closeModal: (props?: CloseModalProps) => void;
|
|
243
|
+
closeWithoutAnimation: () => void;
|
|
244
|
+
} & SnapController;
|
|
245
|
+
|
|
246
|
+
export type BottomModalRefObject = React.Ref<BottomModalRef>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//$lf-ignore
|
|
2
|
+
import { useAnimatedScrollHandler } from 'react-native-reanimated';
|
|
3
|
+
import { useContext, useRef } from 'react';
|
|
4
|
+
import { BottomSheetContext } from '../components/BottomSheet';
|
|
5
|
+
import type {
|
|
6
|
+
BottomSheetFlatlistProps,
|
|
7
|
+
ReanimatedOnScroll,
|
|
8
|
+
} from '../config/bottomSheet.types';
|
|
9
|
+
import type {
|
|
10
|
+
LayoutChangeEvent,
|
|
11
|
+
NativeScrollEvent,
|
|
12
|
+
NativeSyntheticEvent,
|
|
13
|
+
} from 'react-native';
|
|
14
|
+
|
|
15
|
+
export function bottomFlatlistController<T>(
|
|
16
|
+
props: BottomSheetFlatlistProps<T>
|
|
17
|
+
) {
|
|
18
|
+
let { onScroll, refFlatlist, ...flatlistProps } = props;
|
|
19
|
+
const inverted = flatlistProps.inverted;
|
|
20
|
+
|
|
21
|
+
const context = useContext(BottomSheetContext);
|
|
22
|
+
const contentSize = useRef(0);
|
|
23
|
+
const layoutHeight = useRef(0);
|
|
24
|
+
|
|
25
|
+
const scrollY = context?.scrollY;
|
|
26
|
+
|
|
27
|
+
const animatedScrollHandler = useAnimatedScrollHandler({
|
|
28
|
+
onScroll: (event) => {
|
|
29
|
+
if (scrollY) scrollY.value = event.contentOffset.y;
|
|
30
|
+
if (onScroll) {
|
|
31
|
+
onScroll = onScroll as ReanimatedOnScroll;
|
|
32
|
+
onScroll(event);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (context && refFlatlist)
|
|
38
|
+
context.scrollableComponentRef.current = refFlatlist.current;
|
|
39
|
+
|
|
40
|
+
const onScrollBegin = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
41
|
+
if (!context) {
|
|
42
|
+
if (typeof flatlistProps.onScrollBeginDrag === 'function')
|
|
43
|
+
flatlistProps.onScrollBeginDrag &&
|
|
44
|
+
flatlistProps.onScrollBeginDrag(event);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (context.inverted.value !== inverted)
|
|
48
|
+
context!.inverted.value = !!inverted;
|
|
49
|
+
const maxScrollOffset = contentSize.current - layoutHeight.current;
|
|
50
|
+
if (context.maxScrollOffset.value !== maxScrollOffset)
|
|
51
|
+
context.maxScrollOffset.value = maxScrollOffset;
|
|
52
|
+
if (!context.scrollableComponentRef.current && refFlatlist)
|
|
53
|
+
context.scrollableComponentRef.current = refFlatlist.current;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const onLayout = (e: LayoutChangeEvent) => {
|
|
57
|
+
layoutHeight.current = e.nativeEvent.layout.height;
|
|
58
|
+
inverted && (context!.inverted.value = true);
|
|
59
|
+
if (contentSize.current) {
|
|
60
|
+
context!.maxScrollOffset.value =
|
|
61
|
+
contentSize.current - e.nativeEvent.layout.height;
|
|
62
|
+
}
|
|
63
|
+
if (typeof flatlistProps.onLayout === 'function')
|
|
64
|
+
flatlistProps.onLayout && flatlistProps.onLayout(e);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const onContentSizeChange = (w: number, h: number) => {
|
|
68
|
+
contentSize.current = h;
|
|
69
|
+
if (layoutHeight.current) {
|
|
70
|
+
context!.maxScrollOffset.value = h - layoutHeight.current;
|
|
71
|
+
}
|
|
72
|
+
if (typeof flatlistProps.onContentSizeChange === 'function')
|
|
73
|
+
flatlistProps.onContentSizeChange &&
|
|
74
|
+
flatlistProps.onContentSizeChange(w, h);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
refFlatlist,
|
|
79
|
+
flatlistProps,
|
|
80
|
+
context,
|
|
81
|
+
onScroll,
|
|
82
|
+
onLayout,
|
|
83
|
+
onScrollBegin,
|
|
84
|
+
onContentSizeChange,
|
|
85
|
+
animatedScrollHandler,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { useAnimatedScrollHandler } from 'react-native-reanimated';
|
|
3
|
+
import type {
|
|
4
|
+
BottomSheetScrollViewProps,
|
|
5
|
+
ReanimatedOnScroll,
|
|
6
|
+
} from '../config/bottomSheet.types';
|
|
7
|
+
import { BottomSheetContext } from '../components/BottomSheet';
|
|
8
|
+
|
|
9
|
+
export function bottomScrollViewController(props: BottomSheetScrollViewProps) {
|
|
10
|
+
let { onScroll, refScrollView, ...scrollViewProps } = props;
|
|
11
|
+
|
|
12
|
+
const context = useContext(BottomSheetContext);
|
|
13
|
+
|
|
14
|
+
const scrollY = context?.scrollY;
|
|
15
|
+
|
|
16
|
+
const animatedScrollHandler = useAnimatedScrollHandler({
|
|
17
|
+
onScroll: (event) => {
|
|
18
|
+
if (scrollY) scrollY.value = event.contentOffset.y;
|
|
19
|
+
if (onScroll) {
|
|
20
|
+
onScroll = onScroll as ReanimatedOnScroll;
|
|
21
|
+
onScroll(event);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (context && refScrollView)
|
|
27
|
+
context.scrollableComponentRef.current = refScrollView.current;
|
|
28
|
+
|
|
29
|
+
const assignRef = () => {
|
|
30
|
+
if (!context) return;
|
|
31
|
+
if (!context.scrollableComponentRef.current && refScrollView)
|
|
32
|
+
context.scrollableComponentRef.current = refScrollView.current;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
context,
|
|
37
|
+
onScroll,
|
|
38
|
+
assignRef,
|
|
39
|
+
refScrollView,
|
|
40
|
+
scrollViewProps,
|
|
41
|
+
animatedScrollHandler,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { useDragAnimation } from '../animations/drag.animation';
|
|
2
|
+
import {
|
|
3
|
+
runOnUI,
|
|
4
|
+
useAnimatedStyle,
|
|
5
|
+
useSharedValue,
|
|
6
|
+
withTiming,
|
|
7
|
+
} from 'react-native-reanimated';
|
|
8
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import {
|
|
10
|
+
ModalState,
|
|
11
|
+
type BottomSheetModalProps,
|
|
12
|
+
type ScrollComponentRefProps,
|
|
13
|
+
type SnapPoint,
|
|
14
|
+
} from '../config/bottomSheet.types';
|
|
15
|
+
import { keyboardAnimationController } from './keyboardAnimation.controller';
|
|
16
|
+
import { dragAnimationController } from './dragAnimation.controller';
|
|
17
|
+
import { callbackController } from './callbacks.controller';
|
|
18
|
+
import { scrollContentController } from './scrollContent.controller';
|
|
19
|
+
import { strToNumPercentage } from '@shaquillehinds/react-native-essentials';
|
|
20
|
+
import { useBottomSheetUtils } from './hooks/useBottomSheetUtils';
|
|
21
|
+
|
|
22
|
+
export function bottomSheetController(props: BottomSheetModalProps) {
|
|
23
|
+
const utils = useBottomSheetUtils();
|
|
24
|
+
|
|
25
|
+
const modalState = useRef(ModalState.CLOSED);
|
|
26
|
+
const fullyOpenYPosition = useSharedValue(0);
|
|
27
|
+
const lowestSnapPointPosition = useSharedValue(0);
|
|
28
|
+
const closedYPosition = useSharedValue(0);
|
|
29
|
+
|
|
30
|
+
const currentSnapPoint = useSharedValue<SnapPoint>({
|
|
31
|
+
offset: 0,
|
|
32
|
+
});
|
|
33
|
+
const snapPoints = useSharedValue<SnapPoint[]>(
|
|
34
|
+
(props.snapPoints || []).map((p) => utils.percentageToSnapPoint(p))
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const translationX = useSharedValue(0);
|
|
38
|
+
const translationY = useSharedValue(0);
|
|
39
|
+
const prevTranslationY = useSharedValue(0);
|
|
40
|
+
|
|
41
|
+
const keyboardHeight = useSharedValue(0);
|
|
42
|
+
|
|
43
|
+
const backdropOpacity = useSharedValue(0);
|
|
44
|
+
const contentOpacity = useSharedValue(0);
|
|
45
|
+
const modalContentTranslateY = useSharedValue(0);
|
|
46
|
+
|
|
47
|
+
const scrollY = useSharedValue(0);
|
|
48
|
+
const scrollActive = useSharedValue(false);
|
|
49
|
+
const inverted = useSharedValue(false);
|
|
50
|
+
const maxScrollOffset = useSharedValue(0);
|
|
51
|
+
|
|
52
|
+
const scrollableComponentRef = useRef<ScrollComponentRefProps>(null);
|
|
53
|
+
|
|
54
|
+
const disableLayoutAnimation = useRef(false);
|
|
55
|
+
const setDisableLayoutAnimation = useCallback((bool: boolean) => {
|
|
56
|
+
disableLayoutAnimation.current = bool;
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
const backdropOpacityStyle = useAnimatedStyle(() => ({
|
|
60
|
+
opacity: backdropOpacity.value,
|
|
61
|
+
}));
|
|
62
|
+
const contentOpacityStyle = useAnimatedStyle(() => ({
|
|
63
|
+
opacity: contentOpacity.value,
|
|
64
|
+
}));
|
|
65
|
+
const modalContentAnimatedStyle = useAnimatedStyle(() => ({
|
|
66
|
+
transform: [{ translateY: modalContentTranslateY.value }],
|
|
67
|
+
}));
|
|
68
|
+
const { dragAnimatedStyle, onDrag, onDragStart } = useDragAnimation({
|
|
69
|
+
translationX,
|
|
70
|
+
translationY,
|
|
71
|
+
prevTranslationY,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const {
|
|
75
|
+
closeModal,
|
|
76
|
+
animateModalOpen,
|
|
77
|
+
animateModalClose,
|
|
78
|
+
animateToPercentage,
|
|
79
|
+
animateToSnapPointIndex,
|
|
80
|
+
onModalBackdropPress,
|
|
81
|
+
onModalContentLayout,
|
|
82
|
+
onPlatformViewLayout,
|
|
83
|
+
onRequestClose,
|
|
84
|
+
} = callbackController({
|
|
85
|
+
utils,
|
|
86
|
+
unMounter: props._unMounter,
|
|
87
|
+
snapPoints,
|
|
88
|
+
modalState,
|
|
89
|
+
translationX,
|
|
90
|
+
translationY,
|
|
91
|
+
onBackDropPress: props.onBackDropPress,
|
|
92
|
+
backdropOpacity,
|
|
93
|
+
closedYPosition,
|
|
94
|
+
currentSnapPoint,
|
|
95
|
+
prevTranslationY,
|
|
96
|
+
fullyOpenYPosition,
|
|
97
|
+
disableLayoutAnimation,
|
|
98
|
+
setDisableLayoutAnimation,
|
|
99
|
+
onSnapPointReach: props.onSnapPointReach,
|
|
100
|
+
disableCloseOnBackdropPress: props.disableCloseOnBackdropPress,
|
|
101
|
+
setShowModal: props.setShowModal,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const [modalDimensionsStyle, setModalDimensionsStyle] = useState({
|
|
105
|
+
width: utils.screenWidth,
|
|
106
|
+
height: utils.modalHeight,
|
|
107
|
+
bottom: utils.modalBottomOffset,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const percentToSnapPoint = (p: string | number) => {
|
|
112
|
+
const percentage = strToNumPercentage(p);
|
|
113
|
+
return {
|
|
114
|
+
percentage: percentage / 100,
|
|
115
|
+
offset: -(utils.relativeY(percentage) + utils.extraHeight),
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
const newSnapPoints = (props.snapPoints || []).map((p) =>
|
|
119
|
+
percentToSnapPoint(p)
|
|
120
|
+
);
|
|
121
|
+
snapPoints.value = newSnapPoints;
|
|
122
|
+
setModalDimensionsStyle({
|
|
123
|
+
height: utils.modalHeight,
|
|
124
|
+
bottom: -utils.modalHeight * 2,
|
|
125
|
+
width: utils.relativeX(100),
|
|
126
|
+
});
|
|
127
|
+
if (newSnapPoints.length) {
|
|
128
|
+
const { firstSnapPoint, maxSnapPoint, minSnapPoint } =
|
|
129
|
+
utils.getMaxMinSnapPoints(newSnapPoints);
|
|
130
|
+
currentSnapPoint.value = firstSnapPoint;
|
|
131
|
+
fullyOpenYPosition.value = maxSnapPoint;
|
|
132
|
+
lowestSnapPointPosition.value = minSnapPoint;
|
|
133
|
+
setTimeout(() => {
|
|
134
|
+
if (!modalState.current || modalState.current === ModalState.CLOSING)
|
|
135
|
+
return;
|
|
136
|
+
animateToSnapPointIndex(0);
|
|
137
|
+
}, 500);
|
|
138
|
+
}
|
|
139
|
+
}, [utils.orientation]);
|
|
140
|
+
|
|
141
|
+
const { onDragEndGesture, onDragGesture, onDragStartGesture } =
|
|
142
|
+
dragAnimationController({
|
|
143
|
+
onDrag,
|
|
144
|
+
onDragStart,
|
|
145
|
+
closeModal,
|
|
146
|
+
snapPoints,
|
|
147
|
+
currentSnapPoint,
|
|
148
|
+
keyboardHeight,
|
|
149
|
+
translationY,
|
|
150
|
+
prevTranslationY,
|
|
151
|
+
closedYPosition,
|
|
152
|
+
fullyOpenYPosition,
|
|
153
|
+
backdropOpacity,
|
|
154
|
+
keepMounted: props.keepMounted,
|
|
155
|
+
onSnapPointReach: props.onSnapPointReach,
|
|
156
|
+
lowestSnapPointPosition,
|
|
157
|
+
allowDragWhileKeyboardVisible: props.allowDragWhileKeyboardVisible,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
keyboardAnimationController({
|
|
161
|
+
keyboardHeight,
|
|
162
|
+
translationY,
|
|
163
|
+
screenHeight: utils.screenHeight,
|
|
164
|
+
prevTranslationY,
|
|
165
|
+
modalContentTranslateY,
|
|
166
|
+
setDisableLayoutAnimation,
|
|
167
|
+
avoidKeyboard: props.avoidKeyboard,
|
|
168
|
+
inputsForKeyboardToAvoid: props.inputsForKeyboardToAvoid,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const { onBeginScroll, onUpdateScroll, onEndScroll } =
|
|
172
|
+
scrollContentController({
|
|
173
|
+
scrollableComponentRef,
|
|
174
|
+
onDragStartGesture,
|
|
175
|
+
onDragGesture,
|
|
176
|
+
onDragEndGesture,
|
|
177
|
+
maxScrollOffset,
|
|
178
|
+
scrollActive,
|
|
179
|
+
inverted,
|
|
180
|
+
scrollY,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
const animateContentDelay = () => {
|
|
185
|
+
if (props.showContentDelay) {
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
contentOpacity.value = withTiming(1, { duration: 500 });
|
|
188
|
+
}, props.showContentDelay.timeInMilliSecs);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
if (props.showModal === undefined) animateContentDelay();
|
|
192
|
+
else if (!props.showModal && !disableLayoutAnimation.current) {
|
|
193
|
+
setDisableLayoutAnimation(true);
|
|
194
|
+
runOnUI(animateModalClose)();
|
|
195
|
+
} else if (props.showModal) animateContentDelay();
|
|
196
|
+
}, [props.showModal]);
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
modalState,
|
|
200
|
+
|
|
201
|
+
scrollY,
|
|
202
|
+
inverted,
|
|
203
|
+
onEndScroll,
|
|
204
|
+
onBeginScroll,
|
|
205
|
+
onUpdateScroll,
|
|
206
|
+
maxScrollOffset,
|
|
207
|
+
scrollableComponentRef,
|
|
208
|
+
|
|
209
|
+
disableLayoutAnimation,
|
|
210
|
+
|
|
211
|
+
animateModalOpen,
|
|
212
|
+
animateModalClose,
|
|
213
|
+
animateToPercentage,
|
|
214
|
+
animateToSnapPointIndex,
|
|
215
|
+
|
|
216
|
+
onDragGesture,
|
|
217
|
+
onDragStartGesture,
|
|
218
|
+
onDragEndGesture,
|
|
219
|
+
|
|
220
|
+
onPlatformViewLayout,
|
|
221
|
+
onModalContentLayout,
|
|
222
|
+
|
|
223
|
+
onRequestClose,
|
|
224
|
+
onModalBackdropPress,
|
|
225
|
+
|
|
226
|
+
dragAnimatedStyle,
|
|
227
|
+
modalContentAnimatedStyle,
|
|
228
|
+
backdropOpacityStyle,
|
|
229
|
+
contentOpacityStyle,
|
|
230
|
+
modalDimensionsStyle,
|
|
231
|
+
|
|
232
|
+
screenHeight: utils.screenHeight,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type BottomSheetControllerReturn = ReturnType<
|
|
237
|
+
typeof bottomSheetController
|
|
238
|
+
>;
|