Skip to content

Commit d5df801

Browse files
chore: use bottom sheet from design system package
1 parent 4ecd167 commit d5df801

2 files changed

Lines changed: 36 additions & 37 deletions

File tree

app/components/UI/Bridge/components/HighRateAlertModal/HighRateAlertModal.test.tsx

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,39 @@ import { HighRateAlertModalSelectorsIDs } from './HighRateAlertModal.testIds';
66
import { BridgeToken } from '../../types';
77

88
const mockGoToSwaps = jest.fn();
9+
const mockGoBack = jest.fn();
910

10-
jest.mock(
11-
'../../../../../component-library/components/BottomSheets/BottomSheet',
12-
() => {
13-
const ReactActual = jest.requireActual('react');
14-
const { View } = jest.requireActual('react-native');
15-
16-
return {
17-
__esModule: true,
18-
default: ReactActual.forwardRef(
19-
(
20-
{
21-
children,
22-
testID,
23-
}: {
24-
children?: React.ReactNode;
25-
testID?: string;
26-
},
27-
ref: React.Ref<{
28-
onCloseBottomSheet: (callback?: () => void) => void;
29-
}>,
30-
) => {
31-
ReactActual.useImperativeHandle(ref, () => ({
32-
onCloseBottomSheet: (callback?: () => void) => {
33-
callback?.();
34-
},
35-
}));
36-
37-
return <View testID={testID}>{children}</View>;
38-
},
39-
),
40-
};
41-
},
42-
);
11+
jest.mock('@react-navigation/native', () => ({
12+
useNavigation: () => ({ goBack: mockGoBack }),
13+
}));
4314

4415
jest.mock('@metamask/design-system-react-native', () => {
16+
const ReactActual = jest.requireActual('react');
4517
const { Pressable, Text, View } = jest.requireActual('react-native');
4618

4719
return {
20+
BottomSheet: ReactActual.forwardRef(
21+
(
22+
{
23+
children,
24+
testID,
25+
}: {
26+
children?: React.ReactNode;
27+
testID?: string;
28+
},
29+
ref: React.Ref<{
30+
onCloseBottomSheet: (callback?: () => void) => void;
31+
}>,
32+
) => {
33+
ReactActual.useImperativeHandle(ref, () => ({
34+
onCloseBottomSheet: (callback?: () => void) => {
35+
callback?.();
36+
},
37+
}));
38+
39+
return <View testID={testID}>{children}</View>;
40+
},
41+
),
4842
BottomSheetFooter: ({
4943
primaryButtonProps,
5044
}: {

app/components/UI/Bridge/components/HighRateAlertModal/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, { useCallback, useRef } from 'react';
2+
import { useNavigation } from '@react-navigation/native';
23
import {
4+
BottomSheet,
35
BottomSheetFooter,
46
BottomSheetHeader,
7+
BottomSheetRef,
58
Box,
69
ButtonIconSize,
710
Text,
811
TextColor,
912
TextVariant,
1013
} from '@metamask/design-system-react-native';
11-
import BottomSheet, {
12-
BottomSheetRef,
13-
} from '../../../../../component-library/components/BottomSheets/BottomSheet';
1414
import { strings } from '../../../../../../locales/i18n';
1515
import { useParams } from '../../../../../util/navigation/navUtils';
1616
import { BridgeToken } from '../../types';
@@ -27,6 +27,7 @@ export interface HighRateAlertModalParams {
2727

2828
export function HighRateAlertModal() {
2929
const sheetRef = useRef<BottomSheetRef>(null);
30+
const { goBack } = useNavigation();
3031
const { sourceToken, destToken } = useParams<HighRateAlertModalParams>();
3132
const { goToSwaps } = useSwapBridgeNavigation({
3233
location: SwapBridgeNavigationLocation.MainView,
@@ -44,7 +45,11 @@ export function HighRateAlertModal() {
4445
}, [destToken, goToSwaps, sourceToken]);
4546

4647
return (
47-
<BottomSheet ref={sheetRef} testID={HighRateAlertModalSelectorsIDs.SHEET}>
48+
<BottomSheet
49+
ref={sheetRef}
50+
goBack={goBack}
51+
testID={HighRateAlertModalSelectorsIDs.SHEET}
52+
>
4853
<BottomSheetHeader
4954
onClose={handleClose}
5055
closeButtonProps={{

0 commit comments

Comments
 (0)