Skip to content

Commit 7366037

Browse files
committed
fix(bottom-sheet): drop leftover @gorhom imports after merge
1 parent ee354fd commit 7366037

4 files changed

Lines changed: 35 additions & 27 deletions

File tree

__tests__/useConfirm.test.tsx

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,57 @@
1-
import React from 'react';
1+
import React, { type ReactNode } from 'react';
22
import { Alert, Platform, Pressable, Text } from 'react-native';
33
import {
44
render,
55
screen,
66
fireEvent,
77
waitFor,
88
} from '@testing-library/react-native';
9+
import type { AppBottomSheetRef } from '../components/bottomSheets/AppBottomSheet';
10+
import type { WarningSheetData } from '../components/bottomSheets/WarningSheet';
911

1012
jest.mock('../context/ThemeContext', () => ({
1113
useTheme: () => ({ theme: require('./helpers/renderWithTheme').testTheme }),
1214
}));
1315

14-
jest.mock('@gorhom/bottom-sheet', () => {
15-
const ReactModule = require('react');
16+
type MockSheetProps = {
17+
onDismiss?: () => void;
18+
children: ReactNode | ((state: { data?: WarningSheetData }) => ReactNode);
19+
};
20+
21+
jest.mock('../components/bottomSheets/AppBottomSheet', () => {
22+
const ReactModule: typeof React = require('react');
1623
const { View } = require('react-native');
1724

18-
const BottomSheetModal = ReactModule.forwardRef((props: any, ref: any) => {
19-
const [data, setData] = ReactModule.useState(null);
25+
const AppBottomSheet = ReactModule.forwardRef<
26+
AppBottomSheetRef<WarningSheetData>,
27+
MockSheetProps
28+
>((props, ref) => {
29+
const [state, setState] = ReactModule.useState<{
30+
data?: WarningSheetData;
31+
} | null>(null);
32+
33+
const close = () => {
34+
setState(null);
35+
props.onDismiss?.();
36+
};
2037

2138
ReactModule.useImperativeHandle(ref, () => ({
22-
present: (presented: any) => setData(presented ?? {}),
23-
dismiss: () => {
24-
setData(null);
25-
props.onDismiss?.();
26-
},
39+
present: (data?: WarningSheetData) => setState({ data }),
40+
dismiss: close,
41+
close,
2742
}));
2843

29-
if (!data) return null;
44+
if (!state) return null;
3045
return (
3146
<View>
3247
{typeof props.children === 'function'
33-
? props.children({ data })
48+
? props.children(state)
3449
: props.children}
3550
</View>
3651
);
3752
});
3853

39-
return {
40-
BottomSheetModal,
41-
BottomSheetView: ({ children, style }: any) => (
42-
<View style={style}>{children}</View>
43-
),
44-
BottomSheetBackdrop: () => null,
45-
BottomSheetModalProvider: ({ children }: any) => <>{children}</>,
46-
};
54+
return { AppBottomSheet };
4755
});
4856

4957
import { useConfirm } from '../hooks/useConfirm';

components/drawer/DrawerSearchOverlay.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
GestureHandlerRootView,
1616
Pressable,
1717
} from 'react-native-gesture-handler';
18-
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
18+
import { BottomSheetProvider } from '@swmansion/react-native-bottom-sheet';
1919
import { useReanimatedKeyboardAnimation } from 'react-native-keyboard-controller';
2020
import { useTheme } from '../../context/ThemeContext';
2121
import { Theme } from '../../styles/colors';
@@ -100,7 +100,7 @@ export const DrawerSearchOverlay = ({
100100
onRequestClose={onRequestClose}
101101
>
102102
<GestureHandlerRootView style={styles.root}>
103-
<BottomSheetModalProvider>
103+
<BottomSheetProvider>
104104
<Animated.View
105105
style={[styles.backdrop, backdropStyle]}
106106
pointerEvents="none"
@@ -128,7 +128,7 @@ export const DrawerSearchOverlay = ({
128128
/>
129129
</View>
130130
</Animated.View>
131-
</BottomSheetModalProvider>
131+
</BottomSheetProvider>
132132
</GestureHandlerRootView>
133133
</Modal>
134134
);

components/drawer/useDrawerChatMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback, useRef, useState } from 'react';
22
import { ActionSheetIOS, Platform } from 'react-native';
33
import { useRouter, usePathname } from 'expo-router';
4-
import { BottomSheetModal } from '@gorhom/bottom-sheet';
4+
import type { AppBottomSheetRef } from '../bottomSheets/AppBottomSheet';
55
import { Chat } from '../../database/chatRepository';
66
import { useChatActions } from '../../hooks/useChatActions';
77
import { Feedback } from '../../utils/Feedback';
@@ -26,7 +26,7 @@ export const useDrawerChatMenu = ({ onMenuActiveChange }: Options = {}) => {
2626
const pathname = usePathname();
2727
const [targetChat, setTargetChat] = useState<Chat | null>(null);
2828
const [renameVisible, setRenameVisible] = useState(false);
29-
const androidSheetRef = useRef<BottomSheetModal>(null);
29+
const androidSheetRef = useRef<AppBottomSheetRef>(null);
3030
const actionPendingRef = useRef(false);
3131

3232
const { rename, exportChat, confirmDelete, ConfirmElement } = useChatActions({

hooks/useConfirm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useCallback, useRef } from 'react';
22
import { Alert, Platform } from 'react-native';
3-
import { BottomSheetModal } from '@gorhom/bottom-sheet';
3+
import type { AppBottomSheetRef } from '../components/bottomSheets/AppBottomSheet';
44
import WarningSheet, {
55
WarningSheetData,
66
} from '../components/bottomSheets/WarningSheet';
@@ -12,7 +12,7 @@ export interface ConfirmOptions {
1212
}
1313

1414
export const useConfirm = () => {
15-
const sheetRef = useRef<BottomSheetModal<WarningSheetData>>(null);
15+
const sheetRef = useRef<AppBottomSheetRef<WarningSheetData>>(null);
1616
const resolveRef = useRef<((confirmed: boolean) => void) | null>(null);
1717

1818
const settle = useCallback((confirmed: boolean) => {

0 commit comments

Comments
 (0)