@umituz/react-native-bottom-sheet 1.1.11 → 1.2.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-bottom-sheet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Modern, performant bottom sheets for React Native with preset configurations, keyboard handling, and smooth animations",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@gorhom/bottom-sheet": ">=5.0.0",
|
|
33
|
+
"@umituz/react-native-animation": "*",
|
|
33
34
|
"@umituz/react-native-design-system": "*",
|
|
34
35
|
"@umituz/react-native-design-system-theme": "*",
|
|
35
36
|
"react": ">=18.2.0",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
43
44
|
"@types/react": "^18.2.45",
|
|
44
45
|
"@types/react-native": "^0.73.0",
|
|
46
|
+
"@umituz/react-native-animation": "latest",
|
|
45
47
|
"@umituz/react-native-design-system": "latest",
|
|
46
48
|
"@umituz/react-native-design-system-theme": "latest",
|
|
47
49
|
"react": "^18.2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
import React, { forwardRef, useCallback, useMemo
|
|
32
|
+
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
33
33
|
import { StyleSheet } from 'react-native';
|
|
34
34
|
import GorhomBottomSheet, {
|
|
35
35
|
BottomSheetView,
|
|
@@ -37,6 +37,7 @@ import GorhomBottomSheet, {
|
|
|
37
37
|
type BottomSheetBackdropProps,
|
|
38
38
|
} from '@gorhom/bottom-sheet';
|
|
39
39
|
import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
|
|
40
|
+
import { useReanimatedReady } from '@umituz/react-native-animation';
|
|
40
41
|
import type {
|
|
41
42
|
BottomSheetConfig,
|
|
42
43
|
BottomSheetPreset,
|
|
@@ -154,7 +155,8 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
154
155
|
) => {
|
|
155
156
|
const tokens = useAppDesignTokens();
|
|
156
157
|
const sheetRef = React.useRef<GorhomBottomSheet>(null);
|
|
157
|
-
|
|
158
|
+
// Use centralized Reanimated ready check from animation package
|
|
159
|
+
const isMounted = useReanimatedReady();
|
|
158
160
|
|
|
159
161
|
// Get configuration from preset or custom (must be before useImperativeHandle)
|
|
160
162
|
const config: BottomSheetConfig = useMemo(() => {
|
|
@@ -185,30 +187,6 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
|
|
|
185
187
|
enableDynamicSizing,
|
|
186
188
|
]);
|
|
187
189
|
|
|
188
|
-
// Ensure component is mounted after Reanimated is ready
|
|
189
|
-
// This prevents layoutState.get errors during initial render
|
|
190
|
-
// @gorhom/bottom-sheet uses useAnimatedDetents which accesses layoutState.get
|
|
191
|
-
// during initialization, so we need to wait for Reanimated to be fully ready
|
|
192
|
-
useEffect(() => {
|
|
193
|
-
// Use a longer delay to ensure Reanimated is fully initialized
|
|
194
|
-
// This is critical because @gorhom/bottom-sheet's internal hooks
|
|
195
|
-
// access layoutState.get immediately when the component renders
|
|
196
|
-
const timer = setTimeout(() => {
|
|
197
|
-
// Use multiple animation frames to ensure Reanimated worklets are ready
|
|
198
|
-
requestAnimationFrame(() => {
|
|
199
|
-
requestAnimationFrame(() => {
|
|
200
|
-
requestAnimationFrame(() => {
|
|
201
|
-
setIsMounted(true);
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}, 500); // Increased delay to 500ms to ensure Reanimated is fully initialized
|
|
206
|
-
|
|
207
|
-
return () => {
|
|
208
|
-
clearTimeout(timer);
|
|
209
|
-
};
|
|
210
|
-
}, []);
|
|
211
|
-
|
|
212
190
|
// Render backdrop component (must be before early return to maintain hook order)
|
|
213
191
|
const renderBackdrop = useCallback(
|
|
214
192
|
(props: BottomSheetBackdropProps) =>
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
import React, { forwardRef, useCallback, useMemo
|
|
33
|
+
import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
34
34
|
import { StyleSheet } from 'react-native';
|
|
35
35
|
import {
|
|
36
36
|
BottomSheetModal as GorhomBottomSheetModal,
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
type BottomSheetBackdropProps,
|
|
40
40
|
} from '@gorhom/bottom-sheet';
|
|
41
41
|
import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
|
|
42
|
+
import { useReanimatedReady } from '@umituz/react-native-animation';
|
|
42
43
|
import type {
|
|
43
44
|
BottomSheetConfig,
|
|
44
45
|
BottomSheetPreset,
|
|
@@ -156,7 +157,8 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
|
|
|
156
157
|
) => {
|
|
157
158
|
const tokens = useAppDesignTokens();
|
|
158
159
|
const modalRef = React.useRef<GorhomBottomSheetModal>(null);
|
|
159
|
-
|
|
160
|
+
// Use centralized Reanimated ready check from animation package
|
|
161
|
+
const isMounted = useReanimatedReady();
|
|
160
162
|
|
|
161
163
|
// Get configuration from preset or custom (must be before useImperativeHandle)
|
|
162
164
|
const config: BottomSheetConfig = useMemo(() => {
|
|
@@ -187,30 +189,6 @@ export const BottomSheetModal = forwardRef<BottomSheetModalRef, BottomSheetModal
|
|
|
187
189
|
enableDynamicSizing,
|
|
188
190
|
]);
|
|
189
191
|
|
|
190
|
-
// Ensure component is mounted after Reanimated is ready
|
|
191
|
-
// This prevents layoutState.get errors during initial render
|
|
192
|
-
// @gorhom/bottom-sheet uses useAnimatedDetents which accesses layoutState.get
|
|
193
|
-
// during initialization, so we need to wait for Reanimated to be fully ready
|
|
194
|
-
useEffect(() => {
|
|
195
|
-
// Use a longer delay to ensure Reanimated is fully initialized
|
|
196
|
-
// This is critical because @gorhom/bottom-sheet's internal hooks
|
|
197
|
-
// access layoutState.get immediately when the component renders
|
|
198
|
-
const timer = setTimeout(() => {
|
|
199
|
-
// Use multiple animation frames to ensure Reanimated worklets are ready
|
|
200
|
-
requestAnimationFrame(() => {
|
|
201
|
-
requestAnimationFrame(() => {
|
|
202
|
-
requestAnimationFrame(() => {
|
|
203
|
-
setIsMounted(true);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
}, 500); // Increased delay to 500ms to ensure Reanimated is fully initialized
|
|
208
|
-
|
|
209
|
-
return () => {
|
|
210
|
-
clearTimeout(timer);
|
|
211
|
-
};
|
|
212
|
-
}, []);
|
|
213
|
-
|
|
214
192
|
// Render backdrop component (must be before early return to maintain hook order)
|
|
215
193
|
const renderBackdrop = useCallback(
|
|
216
194
|
(props: BottomSheetBackdropProps) =>
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import React
|
|
19
|
+
import React from 'react';
|
|
20
20
|
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
21
|
+
import { useReanimatedReady } from '@umituz/react-native-animation';
|
|
21
22
|
|
|
22
23
|
interface SafeBottomSheetModalProviderProps {
|
|
23
24
|
children: React.ReactNode;
|
|
@@ -32,27 +33,8 @@ interface SafeBottomSheetModalProviderProps {
|
|
|
32
33
|
export const SafeBottomSheetModalProvider: React.FC<SafeBottomSheetModalProviderProps> = ({
|
|
33
34
|
children,
|
|
34
35
|
}) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
// Wait for Reanimated to be fully initialized
|
|
39
|
-
// @gorhom/bottom-sheet uses useAnimatedDetents which accesses layoutState.get
|
|
40
|
-
// during initialization, so we need to wait for Reanimated to be fully ready
|
|
41
|
-
const timer = setTimeout(() => {
|
|
42
|
-
// Use multiple animation frames to ensure Reanimated worklets are ready
|
|
43
|
-
requestAnimationFrame(() => {
|
|
44
|
-
requestAnimationFrame(() => {
|
|
45
|
-
requestAnimationFrame(() => {
|
|
46
|
-
setIsReanimatedReady(true);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}, 500); // Delay to ensure Reanimated is fully initialized
|
|
51
|
-
|
|
52
|
-
return () => {
|
|
53
|
-
clearTimeout(timer);
|
|
54
|
-
};
|
|
55
|
-
}, []);
|
|
36
|
+
// Use centralized Reanimated ready check from animation package
|
|
37
|
+
const isReanimatedReady = useReanimatedReady();
|
|
56
38
|
|
|
57
39
|
// Don't render BottomSheetModalProvider until Reanimated is ready
|
|
58
40
|
if (!isReanimatedReady) {
|