Skip to content

Commit 8664701

Browse files
committed
fix(ui): use imperative API for sheets
1 parent 23d49c4 commit 8664701

File tree

9 files changed

+29
-33
lines changed

9 files changed

+29
-33
lines changed

src/components/PinPad.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FadeIn, FadeOut } from 'react-native-reanimated';
66
import BitkitLogo from '../assets/bitkit-logo.svg';
77
import { PIN_ATTEMPTS } from '../constants/app';
88
import usePIN from '../hooks/pin';
9-
import { showBottomSheet } from '../store/utils/ui';
9+
import { useSheetRef } from '../navigation/bottom-sheet/SheetRefsProvider';
1010
import { AnimatedView, View as ThemedView } from '../styles/components';
1111
import { FaceIdIcon, TouchIdIcon } from '../styles/icons';
1212
import { BodyS, Subtitle } from '../styles/text';
@@ -31,6 +31,7 @@ const PinPad = ({
3131
onShowBiotmetrics?: () => void;
3232
}): ReactElement => {
3333
const { t } = useTranslation('security');
34+
const sheetRef = useSheetRef('forgotPIN');
3435
const [biometryData, setBiometricData] = useState<IsSensorAvailableResult>();
3536
const { attemptsRemaining, Dots, handleNumberPress, isLastAttempt, loading } =
3637
usePIN(onSuccess);
@@ -89,7 +90,7 @@ const PinPad = ({
8990
) : (
9091
<Pressable
9192
onPress={(): void => {
92-
showBottomSheet('forgotPIN');
93+
sheetRef.current?.present();
9394
}}>
9495
<BodyS testID="AttemptsRemaining" color="brand">
9596
{t('pin_attempts', { attemptsRemaining })}

src/screens/Activity/ActivityListShort.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { StyleSheet, View } from 'react-native';
1111

1212
import Button from '../../components/buttons/Button';
1313
import { useAppSelector } from '../../hooks/redux';
14+
import { useSheetRef } from '../../navigation/bottom-sheet/SheetRefsProvider';
1415
import type { RootNavigationProp } from '../../navigation/types';
1516
import { activityItemsSelector } from '../../store/reselect/activity';
1617
import { IActivityItem } from '../../store/types/activity';
17-
import { showBottomSheet } from '../../store/utils/ui';
1818
import { Caption13Up } from '../../styles/text';
1919
import { groupActivityItems } from '../../utils/activity';
2020
import ListItem, { EmptyItem } from './ListItem';
@@ -24,6 +24,7 @@ const MAX_ACTIVITY_ITEMS = 3;
2424
const ActivityListShort = (): ReactElement => {
2525
const { t } = useTranslation('wallet');
2626
const navigation = useNavigation<RootNavigationProp>();
27+
const sheetRef = useSheetRef('receiveNavigation');
2728
const items = useAppSelector(activityItemsSelector);
2829

2930
const groupedItems = useMemo(() => {
@@ -57,8 +58,9 @@ const ActivityListShort = (): ReactElement => {
5758
[navigation],
5859
);
5960

61+
// biome-ignore lint/correctness/useExhaustiveDependencies: sheetRef doesn't change
6062
const navigateToReceive = useCallback((): void => {
61-
showBottomSheet('receiveNavigation');
63+
sheetRef.current?.present();
6264
}, []);
6365

6466
const navigateToActivityFiltered = useCallback((): void => {

src/screens/Profile/ProfileEdit.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import React, {
88
} from 'react';
99
import { useTranslation } from 'react-i18next';
1010
import { StyleSheet, View } from 'react-native';
11-
import { useAppDispatch, useAppSelector } from '../../hooks/redux';
1211

1312
import Dialog from '../../components/Dialog';
1413
import Divider from '../../components/Divider';
@@ -19,8 +18,10 @@ import ProfileLinks from '../../components/ProfileLinks';
1918
import SafeAreaInset from '../../components/SafeAreaInset';
2019
import Button from '../../components/buttons/Button';
2120
import { Keyboard } from '../../hooks/keyboard';
21+
import { useAppDispatch, useAppSelector } from '../../hooks/redux';
2222
import { useProfile, useSlashtags } from '../../hooks/slashtags';
2323
import ProfileLinkNavigation from '../../navigation/bottom-sheet/ProfileLinkNavigation';
24+
import { useSheetRef } from '../../navigation/bottom-sheet/SheetRefsProvider';
2425
import type { RootStackScreenProps } from '../../navigation/types';
2526
import { slashtagsLinksSelector } from '../../store/reselect/slashtags';
2627
import { onboardingProfileStepSelector } from '../../store/reselect/slashtags';
@@ -29,7 +30,6 @@ import {
2930
setOnboardingProfileStep,
3031
} from '../../store/slices/slashtags';
3132
import { BasicProfile } from '../../store/types/slashtags';
32-
import { showBottomSheet } from '../../store/utils/ui';
3333
import { ScrollView, View as ThemedView } from '../../styles/components';
3434
import { PlusIcon } from '../../styles/icons';
3535
import { BodyS } from '../../styles/text';
@@ -48,6 +48,7 @@ const ProfileEdit = ({
4848
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
4949
const [fields, setFields] = useState<Omit<BasicProfile, 'links'>>({});
5050
const dispatch = useAppDispatch();
51+
const sheetRef = useSheetRef('profileAddDataForm');
5152
const links = useAppSelector(slashtagsLinksSelector);
5253
const onboardingStep = useAppSelector(onboardingProfileStepSelector);
5354

@@ -94,7 +95,7 @@ const ProfileEdit = ({
9495

9596
const onAddLink = async (): Promise<void> => {
9697
await Keyboard.dismiss();
97-
showBottomSheet('profileAddDataForm');
98+
sheetRef.current?.present();
9899
};
99100

100101
const onSave = async (): Promise<void> => {

src/screens/Settings/Backup/ResetAndRestore.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ import Dialog from '../../../components/Dialog';
66
import NavigationHeader from '../../../components/NavigationHeader';
77
import SafeAreaInset from '../../../components/SafeAreaInset';
88
import Button from '../../../components/buttons/Button';
9+
import { useSheetRef } from '../../../navigation/bottom-sheet/SheetRefsProvider';
910
import { wipeApp } from '../../../store/utils/settings';
10-
import { showBottomSheet } from '../../../store/utils/ui';
1111
import { View } from '../../../styles/components';
1212
import { BodyM } from '../../../styles/text';
1313

1414
const imageSrc = require('../../../assets/illustrations/restore.png');
1515

1616
const ResetAndRestore = (): ReactElement => {
1717
const { t } = useTranslation('security');
18+
const sheetRef = useSheetRef('backupNavigation');
1819
const [showDialog, setShowDialog] = useState(false);
1920

2021
return (
@@ -35,7 +36,7 @@ const ResetAndRestore = (): ReactElement => {
3536
style={styles.button}
3637
text={t('reset_button_backup')}
3738
onPress={(): void => {
38-
showBottomSheet('backupNavigation');
39+
sheetRef.current?.present();
3940
}}
4041
/>
4142
<Button

src/screens/Settings/BackupSettings/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { EItemType, IListData } from '../../../components/List';
66
import Button from '../../../components/buttons/Button';
77
import { __E2E__ } from '../../../constants/env';
88
import { useAppDispatch, useAppSelector } from '../../../hooks/redux';
9+
import { useSheetRef } from '../../../navigation/bottom-sheet/SheetRefsProvider';
910
import { SettingsScreenProps } from '../../../navigation/types';
1011
import { backupSelector } from '../../../store/reselect/backup';
1112
import { lightningBackupSelector } from '../../../store/reselect/lightning';
1213
import { forceBackup } from '../../../store/slices/backup';
1314
import { TBackupItem } from '../../../store/types/backup';
1415
import { EBackupCategory } from '../../../store/types/backup';
15-
import { showBottomSheet } from '../../../store/utils/ui';
1616
import { ScrollView, View as ThemedView } from '../../../styles/components';
1717
import {
1818
ArrowClockwise,
@@ -135,6 +135,7 @@ const BackupSettings = ({
135135
navigation,
136136
}: SettingsScreenProps<'BackupSettings'>): ReactElement => {
137137
const { t } = useTranslation('settings');
138+
const sheetRef = useSheetRef('backupNavigation');
138139
const pin = useAppSelector((state) => state.settings.pin);
139140
const backup = useAppSelector(backupSelector);
140141
const lightningBackup = useAppSelector(lightningBackupSelector);
@@ -220,6 +221,7 @@ const BackupSettings = ({
220221
(c) => c.status.synced >= c.status.required,
221222
);
222223

224+
// biome-ignore lint/correctness/useExhaustiveDependencies: sheetRef doesn't change
223225
const settingsListData: IListData[] = useMemo(
224226
() => [
225227
{
@@ -229,7 +231,7 @@ const BackupSettings = ({
229231
type: EItemType.button,
230232
testID: 'BackupWallet',
231233
onPress: (): void => {
232-
showBottomSheet('backupNavigation');
234+
sheetRef.current?.present();
233235
},
234236
},
235237
{

src/screens/Settings/DevSettings/LdkDebug.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import SafeAreaInset from '../../../components/SafeAreaInset';
1111
import Button from '../../../components/buttons/Button';
1212
import { useLightningBalance } from '../../../hooks/lightning';
1313
import { useAppDispatch, useAppSelector } from '../../../hooks/redux';
14+
import { useSheetRef } from '../../../navigation/bottom-sheet/SheetRefsProvider';
1415
import { openChannelsSelector } from '../../../store/reselect/lightning';
1516
import {
1617
selectedNetworkSelector,
@@ -21,7 +22,6 @@ import {
2122
createLightningInvoice,
2223
savePeer,
2324
} from '../../../store/utils/lightning';
24-
import { showBottomSheet } from '../../../store/utils/ui';
2525
import { TextInput, View as ThemedView } from '../../../styles/components';
2626
import { Caption13Up } from '../../../styles/text';
2727
import {
@@ -41,6 +41,7 @@ import { showToast } from '../../../utils/notifications';
4141
const LdkDebug = (): ReactElement => {
4242
const { t } = useTranslation('lightning');
4343
const dispatch = useAppDispatch();
44+
const sheetRef = useSheetRef('forceTransfer');
4445
const [peer, setPeer] = useState('');
4546
const [payingInvoice, setPayingInvoice] = useState(false);
4647
const [refreshingLdk, setRefreshingLdk] = useState(false);
@@ -263,7 +264,7 @@ const LdkDebug = (): ReactElement => {
263264
};
264265

265266
const onForceCloseChannels = (): void => {
266-
showBottomSheet('forceTransfer');
267+
sheetRef.current?.present();
267268
};
268269

269270
const onSpendOutputsFromForceClose = async (): Promise<void> => {

src/screens/Settings/PIN/ChangePin.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ import NumberPad from '../../../components/NumberPad';
88
import SafeAreaInset from '../../../components/SafeAreaInset';
99
import { PIN_ATTEMPTS } from '../../../constants/app';
1010
import usePIN from '../../../hooks/pin';
11+
import { useSheetRef } from '../../../navigation/bottom-sheet/SheetRefsProvider';
1112
import type { SettingsScreenProps } from '../../../navigation/types';
12-
import { showBottomSheet } from '../../../store/utils/ui';
1313
import { AnimatedView, View as ThemedView } from '../../../styles/components';
1414
import { BodyM, BodyS } from '../../../styles/text';
1515

1616
const ChangePin = ({
1717
navigation,
1818
}: SettingsScreenProps<'ChangePin'>): ReactElement => {
1919
const { t } = useTranslation('security');
20+
const sheetRef = useSheetRef('forgotPIN');
21+
2022
const nextStep = useCallback(() => {
2123
navigation.pop();
2224
navigation.navigate('ChangePin2');
2325
}, [navigation]);
26+
2427
const { attemptsRemaining, Dots, handleNumberPress, isLastAttempt, loading } =
2528
usePIN(nextStep);
2629

@@ -47,7 +50,7 @@ const ChangePin = ({
4750
) : (
4851
<Pressable
4952
onPress={(): void => {
50-
showBottomSheet('forgotPIN');
53+
sheetRef.current?.present();
5154
}}>
5255
<BodyS testID="AttemptsRemaining" color="brand">
5356
{t('pin_attempts', { attemptsRemaining })}

src/screens/Transfer/Funding.tsx

-16
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,6 @@ const Funding = ({
8383
onPress={onAdvanced}
8484
/>
8585
</View>
86-
87-
{/* <Dialog
88-
visible={showDialog}
89-
title={t('no_funds.title')}
90-
description={t('no_funds.description')}
91-
buttonColor="purple"
92-
cancelText={t('cancel')}
93-
confirmText={t('no_funds.fund')}
94-
onCancel={(): void => {
95-
setShowDialog(false);
96-
}}
97-
onConfirm={(): void => {
98-
setShowDialog(false);
99-
showBottomSheet('receiveNavigation');
100-
}}
101-
/> */}
10286
<SafeAreaInset type="bottom" minPadding={16} />
10387
</ThemedView>
10488
);

src/screens/Wallets/Send/SendPinPad.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import { FadeIn, FadeOut } from 'react-native-reanimated';
66
import NumberPad from '../../../components/NumberPad';
77
import { PIN_ATTEMPTS } from '../../../constants/app';
88
import usePIN from '../../../hooks/pin';
9-
import { showBottomSheet } from '../../../store/utils/ui';
9+
import { useSheetRef } from '../../../navigation/bottom-sheet/SheetRefsProvider';
1010
import { AnimatedView } from '../../../styles/components';
1111
import { BodyS } from '../../../styles/text';
1212

1313
const SendPinPad = ({ onSuccess }: { onSuccess: () => void }): ReactElement => {
1414
const { t } = useTranslation('security');
15+
const sheetRef = useSheetRef('forgotPIN');
1516
const { attemptsRemaining, Dots, handleNumberPress, isLastAttempt, loading } =
1617
usePIN(onSuccess);
1718

@@ -35,7 +36,7 @@ const SendPinPad = ({ onSuccess }: { onSuccess: () => void }): ReactElement => {
3536
) : (
3637
<Pressable
3738
onPress={(): void => {
38-
showBottomSheet('forgotPIN');
39+
sheetRef.current?.present();
3940
}}>
4041
<BodyS testID="AttemptsRemaining" color="brand">
4142
{t('pin_attempts', { attemptsRemaining })}

0 commit comments

Comments
 (0)