@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
package/src/BottomSheet.tsx
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
|
-
import { useState, type ReactNode } from 'react';
|
|
1
|
+
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
|
2
2
|
import type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
Animated,
|
|
5
|
+
Pressable,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
View,
|
|
8
|
+
useWindowDimensions,
|
|
9
|
+
} from 'react-native';
|
|
5
10
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
11
|
|
|
7
12
|
import BottomSheetNativeComponent from './BottomSheetNativeComponent';
|
|
13
|
+
import { Portal } from './BottomSheetProvider';
|
|
8
14
|
import { type Detent, resolveDetent } from './bottomSheetUtils';
|
|
9
15
|
export type { Detent, DetentValue } from './bottomSheetUtils';
|
|
10
16
|
export { programmatic } from './bottomSheetUtils';
|
|
11
17
|
|
|
18
|
+
const DefaultScrim = ({
|
|
19
|
+
progress,
|
|
20
|
+
color,
|
|
21
|
+
}: {
|
|
22
|
+
progress: Animated.Value;
|
|
23
|
+
color: string;
|
|
24
|
+
}) => {
|
|
25
|
+
return (
|
|
26
|
+
<Animated.View
|
|
27
|
+
style={[
|
|
28
|
+
StyleSheet.absoluteFill,
|
|
29
|
+
{ flex: 1, backgroundColor: color, opacity: progress },
|
|
30
|
+
]}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
12
35
|
export interface BottomSheetProps {
|
|
13
36
|
children: ReactNode;
|
|
14
37
|
style?: StyleProp<ViewStyle>;
|
|
@@ -16,7 +39,9 @@ export interface BottomSheetProps {
|
|
|
16
39
|
index: number;
|
|
17
40
|
animateIn?: boolean;
|
|
18
41
|
onIndexChange?: (index: number) => void;
|
|
19
|
-
|
|
42
|
+
onPositionChange?: (position: number) => void;
|
|
43
|
+
modal?: boolean;
|
|
44
|
+
scrimColor?: string;
|
|
20
45
|
}
|
|
21
46
|
|
|
22
47
|
export const BottomSheet = ({
|
|
@@ -26,12 +51,16 @@ export const BottomSheet = ({
|
|
|
26
51
|
index,
|
|
27
52
|
animateIn = true,
|
|
28
53
|
onIndexChange,
|
|
29
|
-
|
|
54
|
+
onPositionChange,
|
|
55
|
+
modal = false,
|
|
56
|
+
scrimColor = 'rgba(0, 0, 0, 0.5)',
|
|
30
57
|
}: BottomSheetProps) => {
|
|
31
58
|
const { height: screenHeight } = useWindowDimensions();
|
|
32
59
|
const insets = useSafeAreaInsets();
|
|
33
60
|
const maxHeight = screenHeight - insets.top;
|
|
34
61
|
const [contentHeight, setContentHeight] = useState(0);
|
|
62
|
+
const currentPositionRef = useRef(0);
|
|
63
|
+
const scrimProgress = useRef(new Animated.Value(0)).current;
|
|
35
64
|
|
|
36
65
|
const resolvedDetents = detents.map((detent) => {
|
|
37
66
|
const value = resolveDetent(detent, contentHeight, maxHeight);
|
|
@@ -48,6 +77,44 @@ export const BottomSheet = ({
|
|
|
48
77
|
const clampedIndex = Math.max(0, Math.min(index, resolvedDetents.length - 1));
|
|
49
78
|
const isCollapsed = (resolvedDetents[clampedIndex]?.height ?? 0) === 0;
|
|
50
79
|
const sheetPointerEvents = isCollapsed ? 'none' : 'box-none';
|
|
80
|
+
const scrimPressEnabledRef = useRef(!modal || isCollapsed);
|
|
81
|
+
const previousIsCollapsedRef = useRef(isCollapsed);
|
|
82
|
+
const firstNonzeroDetent =
|
|
83
|
+
resolvedDetents.find((detent) => detent.height > 0)?.height ?? 0;
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const progress =
|
|
87
|
+
firstNonzeroDetent <= 0
|
|
88
|
+
? 0
|
|
89
|
+
: Math.min(
|
|
90
|
+
1,
|
|
91
|
+
Math.max(0, currentPositionRef.current / firstNonzeroDetent)
|
|
92
|
+
);
|
|
93
|
+
scrimProgress.setValue(progress);
|
|
94
|
+
}, [firstNonzeroDetent, scrimProgress]);
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!modal) {
|
|
98
|
+
scrimPressEnabledRef.current = true;
|
|
99
|
+
previousIsCollapsedRef.current = isCollapsed;
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (previousIsCollapsedRef.current && !isCollapsed) {
|
|
104
|
+
scrimPressEnabledRef.current = false;
|
|
105
|
+
previousIsCollapsedRef.current = isCollapsed;
|
|
106
|
+
|
|
107
|
+
const frame = requestAnimationFrame(() => {
|
|
108
|
+
scrimPressEnabledRef.current = true;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return () => cancelAnimationFrame(frame);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
scrimPressEnabledRef.current = !isCollapsed;
|
|
115
|
+
previousIsCollapsedRef.current = isCollapsed;
|
|
116
|
+
return undefined;
|
|
117
|
+
}, [isCollapsed, modal]);
|
|
51
118
|
|
|
52
119
|
const handleIndexChange = (event: { nativeEvent: { index: number } }) => {
|
|
53
120
|
onIndexChange?.(event.nativeEvent.index);
|
|
@@ -56,42 +123,82 @@ export const BottomSheet = ({
|
|
|
56
123
|
const handlePositionChange = (event: {
|
|
57
124
|
nativeEvent: { position: number };
|
|
58
125
|
}) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
126
|
+
const height = event.nativeEvent.position;
|
|
127
|
+
currentPositionRef.current = height;
|
|
128
|
+
const progress =
|
|
129
|
+
firstNonzeroDetent <= 0
|
|
130
|
+
? 0
|
|
131
|
+
: Math.min(1, Math.max(0, height / firstNonzeroDetent));
|
|
132
|
+
scrimProgress.setValue(progress);
|
|
133
|
+
onPositionChange?.(height);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const closedIndex = resolvedDetents.findIndex(
|
|
137
|
+
(detent) => detent.height === 0
|
|
138
|
+
);
|
|
139
|
+
const handleScrimPress = () => {
|
|
140
|
+
if (
|
|
141
|
+
closedIndex === -1 ||
|
|
142
|
+
clampedIndex === closedIndex ||
|
|
143
|
+
!scrimPressEnabledRef.current
|
|
144
|
+
) {
|
|
145
|
+
return;
|
|
65
146
|
}
|
|
147
|
+
|
|
148
|
+
onIndexChange?.(closedIndex);
|
|
66
149
|
};
|
|
67
150
|
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
151
|
+
const scrimElement = modal ? (
|
|
152
|
+
<DefaultScrim progress={scrimProgress} color={scrimColor} />
|
|
153
|
+
) : null;
|
|
154
|
+
|
|
155
|
+
const sheet = (
|
|
156
|
+
<Animated.View
|
|
157
|
+
style={StyleSheet.absoluteFill}
|
|
158
|
+
pointerEvents={modal ? (isCollapsed ? 'none' : 'auto') : 'box-none'}
|
|
159
|
+
>
|
|
160
|
+
{modal && scrimElement !== null ? (
|
|
161
|
+
<Pressable style={StyleSheet.absoluteFill} onPress={handleScrimPress}>
|
|
162
|
+
{scrimElement}
|
|
163
|
+
</Pressable>
|
|
164
|
+
) : null}
|
|
165
|
+
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
|
|
166
|
+
<BottomSheetNativeComponent
|
|
167
|
+
pointerEvents={sheetPointerEvents}
|
|
168
|
+
style={[
|
|
169
|
+
{
|
|
170
|
+
position: 'absolute',
|
|
171
|
+
left: 0,
|
|
172
|
+
right: 0,
|
|
173
|
+
bottom: 0,
|
|
174
|
+
height: maxHeight,
|
|
175
|
+
},
|
|
176
|
+
style,
|
|
177
|
+
]}
|
|
178
|
+
detents={resolvedDetents}
|
|
179
|
+
index={index}
|
|
180
|
+
animateIn={animateIn}
|
|
181
|
+
onIndexChange={handleIndexChange}
|
|
182
|
+
onPositionChange={handlePositionChange}
|
|
183
|
+
>
|
|
184
|
+
<View
|
|
185
|
+
collapsable={false}
|
|
186
|
+
style={{ flex: 1 }}
|
|
187
|
+
pointerEvents="box-none"
|
|
188
|
+
>
|
|
189
|
+
{children}
|
|
190
|
+
<View onLayout={handleSentinelLayout} pointerEvents="none" />
|
|
191
|
+
</View>
|
|
192
|
+
</BottomSheetNativeComponent>
|
|
193
|
+
</View>
|
|
194
|
+
</Animated.View>
|
|
94
195
|
);
|
|
196
|
+
|
|
197
|
+
if (modal) {
|
|
198
|
+
return <Portal>{sheet}</Portal>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return sheet;
|
|
95
202
|
};
|
|
96
203
|
|
|
97
204
|
function isDetentProgrammatic(detent: Detent): boolean {
|
package/src/ModalBottomSheet.tsx
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { SharedValue } from 'react-native-reanimated';
|
|
1
|
+
import { BottomSheet, type BottomSheetProps } from './BottomSheet';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export interface ModalBottomSheetProps
|
|
4
|
+
extends Omit<BottomSheetProps, 'modal'> {}
|
|
6
5
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const ModalBottomSheet = ({
|
|
12
|
-
scrim,
|
|
13
|
-
...props
|
|
14
|
-
}: ModalBottomSheetProps) => (
|
|
15
|
-
<BottomSheetBase {...props} modal renderScrim={scrim} />
|
|
6
|
+
export const ModalBottomSheet = (props: ModalBottomSheetProps) => (
|
|
7
|
+
<BottomSheet {...props} modal />
|
|
16
8
|
);
|
package/src/bottomSheetUtils.ts
CHANGED
package/src/index.tsx
CHANGED
|
@@ -3,10 +3,5 @@ export type { BottomSheetProps } from './BottomSheet';
|
|
|
3
3
|
export { ModalBottomSheet } from './ModalBottomSheet';
|
|
4
4
|
export type { ModalBottomSheetProps } from './ModalBottomSheet';
|
|
5
5
|
export { BottomSheetProvider } from './BottomSheetProvider';
|
|
6
|
-
export { BottomSheetFlatList } from './BottomSheetFlatList';
|
|
7
|
-
export type { BottomSheetFlatListProps } from './BottomSheetFlatList';
|
|
8
|
-
export { BottomSheetScrollView } from './BottomSheetScrollView';
|
|
9
|
-
export type { BottomSheetScrollViewProps } from './BottomSheetScrollView';
|
|
10
6
|
export type { Detent, DetentValue } from './bottomSheetUtils';
|
|
11
7
|
export { programmatic } from './bottomSheetUtils';
|
|
12
|
-
export { bottomSheetScrollable } from './bottomSheetScrollable';
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
-
import { Pressable, StyleSheet, View, useWindowDimensions } from 'react-native';
|
|
5
|
-
import Animated, { useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
6
|
-
import { scheduleOnUI } from 'react-native-worklets';
|
|
7
|
-
import { GestureDetector } from 'react-native-gesture-handler';
|
|
8
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
9
|
-
import { Portal } from "./BottomSheetProvider.js";
|
|
10
|
-
import { BottomSheetContextProvider } from "./BottomSheetContext.js";
|
|
11
|
-
import { clampIndex, isDetentProgrammatic, resolveDetent } from "./bottomSheetUtils.js";
|
|
12
|
-
import { useBottomSheetPanGesture } from "./useBottomSheetPanGesture.js";
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
export { programmatic } from "./bottomSheetUtils.js";
|
|
15
|
-
const DEFAULT_OPEN_ANIMATION_CONFIG = {
|
|
16
|
-
dampingRatio: 1,
|
|
17
|
-
duration: 300,
|
|
18
|
-
overshootClamping: true
|
|
19
|
-
};
|
|
20
|
-
const DEFAULT_CLOSE_ANIMATION_CONFIG = {
|
|
21
|
-
dampingRatio: 1,
|
|
22
|
-
duration: 250,
|
|
23
|
-
overshootClamping: true
|
|
24
|
-
};
|
|
25
|
-
const DefaultScrim = ({
|
|
26
|
-
progress
|
|
27
|
-
}) => {
|
|
28
|
-
const style = useAnimatedStyle(() => ({
|
|
29
|
-
opacity: progress.value
|
|
30
|
-
}));
|
|
31
|
-
return /*#__PURE__*/_jsx(Animated.View, {
|
|
32
|
-
style: [StyleSheet.absoluteFill, {
|
|
33
|
-
flex: 1,
|
|
34
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
35
|
-
}, style]
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
export const BottomSheetBase = ({
|
|
39
|
-
children,
|
|
40
|
-
detents = [0, 'max'],
|
|
41
|
-
index,
|
|
42
|
-
onIndexChange,
|
|
43
|
-
position: externalPosition,
|
|
44
|
-
openAnimationConfig = DEFAULT_OPEN_ANIMATION_CONFIG,
|
|
45
|
-
closeAnimationConfig = DEFAULT_CLOSE_ANIMATION_CONFIG,
|
|
46
|
-
modal = false,
|
|
47
|
-
renderScrim
|
|
48
|
-
}) => {
|
|
49
|
-
const {
|
|
50
|
-
height: screenHeight
|
|
51
|
-
} = useWindowDimensions();
|
|
52
|
-
const insets = useSafeAreaInsets();
|
|
53
|
-
const maxHeight = screenHeight - insets.top;
|
|
54
|
-
const resolvedIndex = clampIndex(index, detents.length);
|
|
55
|
-
const [contentHeight, setContentHeight] = useState(0);
|
|
56
|
-
if (detents.length === 0) {
|
|
57
|
-
throw new Error('detents must include at least one value.');
|
|
58
|
-
}
|
|
59
|
-
const normalizedDetents = detents.map(detent => {
|
|
60
|
-
const resolved = resolveDetent(detent, contentHeight, maxHeight);
|
|
61
|
-
return Math.max(0, Math.min(resolved, maxHeight));
|
|
62
|
-
});
|
|
63
|
-
const isDraggable = detents.map(detent => !isDetentProgrammatic(detent));
|
|
64
|
-
const initialMaxSnap = Math.max(0, ...normalizedDetents);
|
|
65
|
-
const translateY = useSharedValue(initialMaxSnap);
|
|
66
|
-
const animationTarget = useSharedValue(NaN);
|
|
67
|
-
const sheetHeight = useSharedValue(initialMaxSnap);
|
|
68
|
-
const [scrollableEntries, setScrollableEntries] = useState([]);
|
|
69
|
-
const isScrollableLocked = useSharedValue(false);
|
|
70
|
-
const registerScrollable = useCallback(entry => {
|
|
71
|
-
setScrollableEntries(prev => [...prev, entry]);
|
|
72
|
-
return () => {
|
|
73
|
-
setScrollableEntries(prev => prev.filter(e => e !== entry));
|
|
74
|
-
};
|
|
75
|
-
}, []);
|
|
76
|
-
const detentsValue = useSharedValue(normalizedDetents);
|
|
77
|
-
const isDraggableValue = useSharedValue(isDraggable);
|
|
78
|
-
const firstNonzeroDetent = useSharedValue(normalizedDetents.find(detent => detent > 0) ?? 0);
|
|
79
|
-
const currentIndex = useSharedValue(resolvedIndex);
|
|
80
|
-
const internalPosition = useDerivedValue(() => Math.max(0, sheetHeight.value - translateY.value));
|
|
81
|
-
useAnimatedReaction(() => internalPosition.value, value => {
|
|
82
|
-
if (externalPosition !== undefined) externalPosition.set(value);
|
|
83
|
-
});
|
|
84
|
-
const scrimProgress = useDerivedValue(() => {
|
|
85
|
-
const target = firstNonzeroDetent.value;
|
|
86
|
-
if (target <= 0) return 0;
|
|
87
|
-
const progress = internalPosition.value / target;
|
|
88
|
-
return Math.min(1, Math.max(0, progress));
|
|
89
|
-
});
|
|
90
|
-
const handleIndexChange = nextIndex => {
|
|
91
|
-
onIndexChange?.(nextIndex);
|
|
92
|
-
};
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
const maxSnap = Math.max(0, ...normalizedDetents);
|
|
95
|
-
detentsValue.set(normalizedDetents);
|
|
96
|
-
isDraggableValue.set(isDraggable);
|
|
97
|
-
sheetHeight.set(maxSnap);
|
|
98
|
-
firstNonzeroDetent.set(normalizedDetents.find(detent => detent > 0) ?? 0);
|
|
99
|
-
}, [normalizedDetents, isDraggable, sheetHeight, detentsValue, isDraggableValue, firstNonzeroDetent]);
|
|
100
|
-
const animateToIndex = useCallback((targetIndex, velocity) => {
|
|
101
|
-
'worklet';
|
|
102
|
-
|
|
103
|
-
const maxSnap = sheetHeight.value;
|
|
104
|
-
const targetTranslate = maxSnap - (detentsValue.value[targetIndex] ?? 0);
|
|
105
|
-
if (animationTarget.value === targetTranslate && velocity === undefined) {
|
|
106
|
-
currentIndex.set(targetIndex);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
animationTarget.set(targetTranslate);
|
|
110
|
-
const isOpening = targetTranslate < translateY.value;
|
|
111
|
-
const baseConfig = isOpening ? openAnimationConfig : closeAnimationConfig;
|
|
112
|
-
const springConfig = velocity === undefined ? baseConfig : {
|
|
113
|
-
...baseConfig,
|
|
114
|
-
velocity
|
|
115
|
-
};
|
|
116
|
-
translateY.set(withSpring(targetTranslate, springConfig));
|
|
117
|
-
currentIndex.set(targetIndex);
|
|
118
|
-
}, [animationTarget, closeAnimationConfig, currentIndex, detentsValue, openAnimationConfig, sheetHeight, translateY]);
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
scheduleOnUI(animateToIndex, resolvedIndex);
|
|
121
|
-
}, [animateToIndex, resolvedIndex, normalizedDetents]);
|
|
122
|
-
const panGesture = useBottomSheetPanGesture({
|
|
123
|
-
animationTarget,
|
|
124
|
-
translateY,
|
|
125
|
-
sheetHeight,
|
|
126
|
-
detentsValue,
|
|
127
|
-
isDraggableValue,
|
|
128
|
-
currentIndex,
|
|
129
|
-
scrollableEntries,
|
|
130
|
-
isScrollableLocked,
|
|
131
|
-
handleIndexChange,
|
|
132
|
-
animateToIndex
|
|
133
|
-
});
|
|
134
|
-
const handleSentinelLayout = event => {
|
|
135
|
-
setContentHeight(event.nativeEvent.layout.y);
|
|
136
|
-
};
|
|
137
|
-
const closedIndex = normalizedDetents.indexOf(0);
|
|
138
|
-
const handleScrimPress = () => {
|
|
139
|
-
if (closedIndex === -1 || resolvedIndex === closedIndex) return;
|
|
140
|
-
handleIndexChange(closedIndex);
|
|
141
|
-
scheduleOnUI(animateToIndex, closedIndex);
|
|
142
|
-
};
|
|
143
|
-
const wrapperStyle = useAnimatedStyle(() => ({
|
|
144
|
-
transform: [{
|
|
145
|
-
translateY: translateY.value
|
|
146
|
-
}],
|
|
147
|
-
height: sheetHeight.value,
|
|
148
|
-
opacity: translateY.value >= sheetHeight.value ? 0 : 1
|
|
149
|
-
}));
|
|
150
|
-
const isCollapsed = normalizedDetents[resolvedIndex] === 0;
|
|
151
|
-
const pointerEvents = modal ? isCollapsed ? 'none' : 'auto' : 'box-none';
|
|
152
|
-
let scrimElement = null;
|
|
153
|
-
if (renderScrim !== undefined) {
|
|
154
|
-
scrimElement = renderScrim(scrimProgress);
|
|
155
|
-
} else if (modal) {
|
|
156
|
-
scrimElement = /*#__PURE__*/_jsx(DefaultScrim, {
|
|
157
|
-
progress: scrimProgress
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
const sheetContent = /*#__PURE__*/_jsx(BottomSheetContextProvider, {
|
|
161
|
-
value: {
|
|
162
|
-
translateY,
|
|
163
|
-
position: internalPosition,
|
|
164
|
-
index: currentIndex,
|
|
165
|
-
sheetHeight,
|
|
166
|
-
isScrollableLocked,
|
|
167
|
-
registerScrollable,
|
|
168
|
-
panGesture
|
|
169
|
-
},
|
|
170
|
-
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
171
|
-
style: [{
|
|
172
|
-
position: 'absolute',
|
|
173
|
-
bottom: 0,
|
|
174
|
-
left: 0,
|
|
175
|
-
right: 0
|
|
176
|
-
}, wrapperStyle],
|
|
177
|
-
pointerEvents: "box-none",
|
|
178
|
-
children: /*#__PURE__*/_jsx(GestureDetector, {
|
|
179
|
-
gesture: panGesture,
|
|
180
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
181
|
-
style: {
|
|
182
|
-
flex: 1
|
|
183
|
-
},
|
|
184
|
-
pointerEvents: "box-none",
|
|
185
|
-
children: [children, /*#__PURE__*/_jsx(View, {
|
|
186
|
-
onLayout: handleSentinelLayout,
|
|
187
|
-
pointerEvents: "none"
|
|
188
|
-
})]
|
|
189
|
-
})
|
|
190
|
-
})
|
|
191
|
-
})
|
|
192
|
-
});
|
|
193
|
-
const sheetContainer = /*#__PURE__*/_jsxs(Animated.View, {
|
|
194
|
-
style: StyleSheet.absoluteFill,
|
|
195
|
-
pointerEvents: pointerEvents,
|
|
196
|
-
children: [modal && scrimElement !== null ? /*#__PURE__*/_jsx(Pressable, {
|
|
197
|
-
style: StyleSheet.absoluteFill,
|
|
198
|
-
onPress: handleScrimPress,
|
|
199
|
-
children: scrimElement
|
|
200
|
-
}) : null, sheetContent]
|
|
201
|
-
});
|
|
202
|
-
if (modal) return /*#__PURE__*/_jsx(Portal, {
|
|
203
|
-
children: sheetContainer
|
|
204
|
-
});
|
|
205
|
-
return sheetContainer;
|
|
206
|
-
};
|
|
207
|
-
//# sourceMappingURL=BottomSheetBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useState","Pressable","StyleSheet","View","useWindowDimensions","Animated","useAnimatedReaction","useAnimatedStyle","useDerivedValue","useSharedValue","withSpring","scheduleOnUI","GestureDetector","useSafeAreaInsets","Portal","BottomSheetContextProvider","clampIndex","isDetentProgrammatic","resolveDetent","useBottomSheetPanGesture","jsx","_jsx","jsxs","_jsxs","programmatic","DEFAULT_OPEN_ANIMATION_CONFIG","dampingRatio","duration","overshootClamping","DEFAULT_CLOSE_ANIMATION_CONFIG","DefaultScrim","progress","style","opacity","value","absoluteFill","flex","backgroundColor","BottomSheetBase","children","detents","index","onIndexChange","position","externalPosition","openAnimationConfig","closeAnimationConfig","modal","renderScrim","height","screenHeight","insets","maxHeight","top","resolvedIndex","length","contentHeight","setContentHeight","Error","normalizedDetents","map","detent","resolved","Math","max","min","isDraggable","initialMaxSnap","translateY","animationTarget","NaN","sheetHeight","scrollableEntries","setScrollableEntries","isScrollableLocked","registerScrollable","entry","prev","filter","e","detentsValue","isDraggableValue","firstNonzeroDetent","find","currentIndex","internalPosition","undefined","set","scrimProgress","target","handleIndexChange","nextIndex","maxSnap","animateToIndex","targetIndex","velocity","targetTranslate","isOpening","baseConfig","springConfig","panGesture","handleSentinelLayout","event","nativeEvent","layout","y","closedIndex","indexOf","handleScrimPress","wrapperStyle","transform","isCollapsed","pointerEvents","scrimElement","sheetContent","bottom","left","right","gesture","onLayout","sheetContainer","onPress"],"sourceRoot":"../../src","sources":["BottomSheetBase.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAE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AI,EAAE;UAAE,CAAE;UAAC4E,aAAa,EAAC,UAAU;UAAAzE,QAAA,GAC/CA,QAAQ,eACTlB,IAAA,CAAClB,IAAI;YAACoH,QAAQ,EAAElB,oBAAqB;YAACW,aAAa,EAAC;UAAM,CAAE,CAAC;QAAA,CACzD;MAAC,CACQ;IAAC,CACL;EAAC,CACU,CAC7B;EAED,MAAMQ,cAAc,gBAClBjG,KAAA,CAAClB,QAAQ,CAACF,IAAI;IACZ6B,KAAK,EAAE9B,UAAU,CAACiC,YAAa;IAC/B6E,aAAa,EAAEA,aAAc;IAAAzE,QAAA,GAE5BQ,KAAK,IAAIkE,YAAY,KAAK,IAAI,gBAC7B5F,IAAA,CAACpB,SAAS;MAAC+B,KAAK,EAAE9B,UAAU,CAACiC,YAAa;MAACsF,OAAO,EAAEb,gBAAiB;MAAArE,QAAA,EAClE0E;IAAY,CACJ,CAAC,GACV,IAAI,EACPC,YAAY;EAAA,CACA,CAChB;EACD,IAAInE,KAAK,EAAE,oBAAO1B,IAAA,CAACP,MAAM;IAAAyB,QAAA,EAAEiF;EAAc,CAAS,CAAC;EAEnD,OAAOA,cAAc;AACvB,CAAC","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { createContext, useContext } from 'react';
|
|
4
|
-
const BottomSheetContext = /*#__PURE__*/createContext(null);
|
|
5
|
-
export const BottomSheetContextProvider = BottomSheetContext.Provider;
|
|
6
|
-
export const useBottomSheetContext = () => {
|
|
7
|
-
const context = useContext(BottomSheetContext);
|
|
8
|
-
if (context === null) {
|
|
9
|
-
throw new Error('`useBottomSheetContext` must be used within `BottomSheet`.');
|
|
10
|
-
}
|
|
11
|
-
return context;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=BottomSheetContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","BottomSheetContext","BottomSheetContextProvider","Provider","useBottomSheetContext","context","Error"],"sourceRoot":"../../src","sources":["BottomSheetContext.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAoBjD,MAAMC,kBAAkB,gBAAGF,aAAa,CAAgC,IAAI,CAAC;AAE7E,OAAO,MAAMG,0BAA0B,GAAGD,kBAAkB,CAACE,QAAQ;AAErE,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACzC,MAAMC,OAAO,GAAGL,UAAU,CAACC,kBAAkB,CAAC;EAC9C,IAAII,OAAO,KAAK,IAAI,EAAE;IACpB,MAAM,IAAIC,KAAK,CACb,4DACF,CAAC;EACH;EACA,OAAOD,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["FlatList","bottomSheetScrollable","BottomSheetFlatList"],"sourceRoot":"../../src","sources":["BottomSheetFlatList.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAgC,cAAc;AAO/D,SAASC,qBAAqB,QAAQ,4BAAyB;AAW/D,OAAO,MAAMC,mBAAmB,GAAGD,qBAAqB,CAACD,QAAQ,CAEhD","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ScrollView","bottomSheetScrollable","BottomSheetScrollView"],"sourceRoot":"../../src","sources":["BottomSheetScrollView.tsx"],"mappings":";;AACA,SACEA,UAAU,QAGL,cAAc;AAGrB,SAASC,qBAAqB,QAAQ,4BAAyB;AAW/D,OAAO,MAAMC,qBAAqB,GAAGD,qBAAqB,CAACD,UAAU,CAEpD","ignoreList":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useImperativeHandle } from 'react';
|
|
4
|
-
import { GestureDetector } from 'react-native-gesture-handler';
|
|
5
|
-
import Animated from 'react-native-reanimated';
|
|
6
|
-
import { useBottomSheetScrollable } from "./useBottomSheetScrollable.js";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
export function bottomSheetScrollable(ScrollableComponent) {
|
|
9
|
-
const AnimatedComponent = Animated.createAnimatedComponent(ScrollableComponent);
|
|
10
|
-
return ({
|
|
11
|
-
scrollEnabled,
|
|
12
|
-
onScroll,
|
|
13
|
-
ref,
|
|
14
|
-
...rest
|
|
15
|
-
}) => {
|
|
16
|
-
const {
|
|
17
|
-
scrollHandler,
|
|
18
|
-
scrollableRef,
|
|
19
|
-
nativeGesture,
|
|
20
|
-
animatedProps
|
|
21
|
-
} = useBottomSheetScrollable(scrollEnabled, onScroll);
|
|
22
|
-
useImperativeHandle(ref, () => scrollableRef.current, [scrollableRef]);
|
|
23
|
-
return /*#__PURE__*/_jsx(GestureDetector, {
|
|
24
|
-
gesture: nativeGesture,
|
|
25
|
-
children: /*#__PURE__*/_jsx(AnimatedComponent, {
|
|
26
|
-
...rest,
|
|
27
|
-
animatedProps: animatedProps,
|
|
28
|
-
ref: scrollableRef,
|
|
29
|
-
onScroll: scrollHandler,
|
|
30
|
-
scrollEventThrottle: 16
|
|
31
|
-
})
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=bottomSheetScrollable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useImperativeHandle","GestureDetector","Animated","useBottomSheetScrollable","jsx","_jsx","bottomSheetScrollable","ScrollableComponent","AnimatedComponent","createAnimatedComponent","scrollEnabled","onScroll","ref","rest","scrollHandler","scrollableRef","nativeGesture","animatedProps","current","gesture","children","scrollEventThrottle"],"sourceRoot":"../../src","sources":["bottomSheetScrollable.tsx"],"mappings":";;AAAA,SAAuCA,mBAAmB,QAAQ,OAAO;AAEzE,SAASC,eAAe,QAAQ,8BAA8B;AAC9D,OAAOC,QAAQ,MAA4B,yBAAyB;AAEpE,SAASC,wBAAwB,QAAQ,+BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtE,OAAO,SAASC,qBAAqBA,CAGnCC,mBAAqC,EAAE;EACvC,MAAMC,iBAAiB,GACrBN,QAAQ,CAACO,uBAAuB,CAACF,mBAAmB,CAAC;EAEvD,OAAO,CAAC;IACNG,aAAa;IACbC,QAAQ;IACRC,GAAG;IACH,GAAGC;EAKL,CAAC,KAAK;IACJ,MAAM;MAAEC,aAAa;MAAEC,aAAa;MAAEC,aAAa;MAAEC;IAAc,CAAC,GAClEd,wBAAwB,CAACO,aAAa,EAAEC,QAAQ,CAAC;IAEnDX,mBAAmB,CAACY,GAAG,EAAE,MAAMG,aAAa,CAACG,OAAY,EAAE,CAACH,aAAa,CAAC,CAAC;IAE3E,oBACEV,IAAA,CAACJ,eAAe;MAACkB,OAAO,EAAEH,aAAc;MAAAI,QAAA,eACtCf,IAAA,CAACG,iBAAiB;QAAA,GACXK,IAAI;QACTI,aAAa,EAAEA,aAAc;QAC7BL,GAAG,EAAEG,aAAc;QACnBJ,QAAQ,EAAEG,aAAc;QACxBO,mBAAmB,EAAE;MAAG,CACzB;IAAC,CACa,CAAC;EAEtB,CAAC;AACH","ignoreList":[]}
|