Skip to content

Commit ad0422a

Browse files
committed
refactor(ui): replace showSheet with sheetRef usage in various components
1 parent 85384df commit ad0422a

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

src/components/TabBar.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import type { RootNavigationProp } from '../navigation/types';
1919
import { useSheetRef } from '../sheets/SheetRefsProvider';
2020
import { resetSendTransaction } from '../store/actions/wallet';
2121
import { spendingOnboardingSelector } from '../store/reselect/aggregations';
22-
import { showSheet } from '../store/utils/ui';
2322
import { ScanIcon } from '../styles/icons';
2423
import ButtonBlur from './buttons/ButtonBlur';
2524

@@ -34,13 +33,13 @@ const TabBar = (): ReactElement => {
3433

3534
const onReceivePress = (): void => {
3635
const currentRoute = rootNavigation.getCurrentRoute();
36+
const screen =
37+
// if we are on the spending screen and the user has not yet received funds
38+
currentRoute === 'ActivitySpending' && isSpendingOnboarding
39+
? 'ReceiveAmount'
40+
: 'ReceiveQR';
3741

38-
// if we are on the spending screen and the user has not yet received funds
39-
if (currentRoute === 'ActivitySpending' && isSpendingOnboarding) {
40-
showSheet('receive', { screen: 'ReceiveAmount' });
41-
} else {
42-
receiveSheetRef.current?.present();
43-
}
42+
receiveSheetRef.current?.present({ screen });
4443
};
4544

4645
const onSendPress = (): void => {

src/screens/Activity/ActivityDetail.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import type {
6666
RootNavigationProp,
6767
RootStackScreenProps,
6868
} from '../../navigation/types';
69+
import { useSheetRef } from '../../sheets/SheetRefsProvider';
6970
import {
7071
activityItemSelector,
7172
activityItemsSelector,
@@ -85,7 +86,6 @@ import {
8586
deleteMetaTxTag,
8687
} from '../../store/slices/metadata';
8788
import { ETransferStatus } from '../../store/types/wallet';
88-
import { showSheet } from '../../store/utils/ui';
8989
import { getBoostedTransactionParents } from '../../utils/boost';
9090
import {
9191
ellipsis,
@@ -159,6 +159,8 @@ const OnchainActivityDetail = ({
159159
const { wallet } = useOnchainWallet();
160160
const { t } = useTranslation('wallet');
161161
const { t: tTime } = useTranslation('intl', { i18n: i18nTime });
162+
const boostSheetRef = useSheetRef('boost');
163+
const activityTagsSheetRef = useSheetRef('activityTags');
162164
const switchUnit = useSwitchUnit();
163165
const dispatch = useAppDispatch();
164166
const contacts = useAppSelector(contactsSelector);
@@ -235,11 +237,11 @@ const OnchainActivityDetail = ({
235237
};
236238

237239
const handleBoost = (): void => {
238-
showSheet('boost', { activityItem: item });
240+
boostSheetRef.current?.present({ activityItem: item });
239241
};
240242

241243
const handleAddTag = (): void => {
242-
showSheet('activityTags', { id });
244+
activityTagsSheetRef.current?.present({ id });
243245
};
244246

245247
const handleRemoveTag = (tag: string): void => {
@@ -678,8 +680,10 @@ const LightningActivityDetail = ({
678680
}): ReactElement => {
679681
const { t } = useTranslation('wallet');
680682
const { t: tTime } = useTranslation('intl', { i18n: i18nTime });
683+
const activityTagsSheetRef = useSheetRef('activityTags');
681684
const switchUnit = useSwitchUnit();
682685
const colors = useColors();
686+
683687
const {
684688
id,
685689
txType,
@@ -700,7 +704,7 @@ const LightningActivityDetail = ({
700704
});
701705

702706
const handleAddTag = (): void => {
703-
showSheet('activityTags', { id });
707+
activityTagsSheetRef.current?.present({ id });
704708
};
705709

706710
const handleRemoveTag = (tag: string): void => {

src/screens/Settings/AddressViewer/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import { updateWallet } from '../../../store/slices/wallet';
4343
import { TWalletName } from '../../../store/types/wallet';
4444
import { updateActivityList } from '../../../store/utils/activity';
4545
import { updateOnchainFeeEstimates } from '../../../store/utils/fees';
46-
import { showSheet } from '../../../store/utils/ui';
4746
import {
4847
View as ThemedView,
4948
TouchableOpacity,
@@ -620,6 +619,7 @@ const AddressViewer = (): ReactElement => {
620619
* The on-chain transaction will retrieve and include the app's receiving address by default.
621620
* Finally, this method will prompt the sendNavigation modal to appear for the user to finalize and confirm the transaction.
622621
*/
622+
// biome-ignore lint/correctness/useExhaustiveDependencies: sheetRef doesn't change
623623
const onSpendFundsPress = useCallback(
624624
async (utxosLength, selectedUtxosLength): Promise<void> => {
625625
if (utxosLength <= 0) {
@@ -649,7 +649,7 @@ const AddressViewer = (): ReactElement => {
649649
}),
650650
);
651651
sendMax();
652-
showSheet('send', { screen: 'ReviewAndSend' });
652+
sendSheetRef.current?.present({ screen: 'ReviewAndSend' });
653653
},
654654
[selectedUtxos, utxos, selectedNetwork, dispatch],
655655
);

src/screens/Settings/Security/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import React, { memo, ReactElement, useMemo, useState, useEffect } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { StyleSheet } from 'react-native';
44

5-
import { View as ThemedView } from '../../../styles/components';
6-
75
import { IsSensorAvailableResult } from '../../../components/Biometrics';
86
import { EItemType, IListData } from '../../../components/List';
97
import { useAppDispatch, useAppSelector } from '../../../hooks/redux';
108
import type { SettingsScreenProps } from '../../../navigation/types';
9+
import { useSheetRef } from '../../../sheets/SheetRefsProvider';
1110
import { updateSettings } from '../../../store/slices/settings';
12-
import { showSheet } from '../../../store/utils/ui';
11+
import { View as ThemedView } from '../../../styles/components';
1312
import rnBiometrics from '../../../utils/biometrics';
1413
import SettingsView from '../SettingsView';
1514

@@ -18,6 +17,7 @@ const SecuritySettings = ({
1817
}: SettingsScreenProps<'SecuritySettings'>): ReactElement => {
1918
const { t } = useTranslation('settings');
2019
const dispatch = useAppDispatch();
20+
const pinSheetRef = useSheetRef('pinNavigation');
2121
const [biometryData, setBiometricData] = useState<IsSensorAvailableResult>();
2222
const {
2323
enableAutoReadClipboard,
@@ -53,6 +53,7 @@ const SecuritySettings = ({
5353
? t('security.footer', { biometryTypeName })
5454
: undefined;
5555

56+
// biome-ignore lint/correctness/useExhaustiveDependencies: sheetRef doesn't change
5657
const settingsListData: IListData[] = useMemo(
5758
() => [
5859
{
@@ -119,7 +120,7 @@ const SecuritySettings = ({
119120
if (pin) {
120121
navigation.navigate('DisablePin');
121122
} else {
122-
showSheet('pinNavigation', { showLaterButton: false });
123+
pinSheetRef.current?.present({ showLaterButton: false });
123124
}
124125
},
125126
},

src/screens/Transfer/Funding.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, { ReactElement } from 'react';
22
import { Trans, useTranslation } from 'react-i18next';
33
import { StyleSheet, View } from 'react-native';
4-
import { useAppSelector } from '../../hooks/redux';
54

65
import NavigationHeader from '../../components/NavigationHeader';
76
import SafeAreaInset from '../../components/SafeAreaInset';
87
import RectangleButton from '../../components/buttons/RectangleButton';
8+
import { useAppSelector } from '../../hooks/redux';
99
import { useBalance } from '../../hooks/wallet';
1010
import type { TransferScreenProps } from '../../navigation/types';
11+
import { useSheetRef } from '../../sheets/SheetRefsProvider';
1112
import { spendingIntroSeenSelector } from '../../store/reselect/settings';
1213
import { isGeoBlockedSelector } from '../../store/reselect/user';
13-
import { showSheet } from '../../store/utils/ui';
1414
import { View as ThemedView } from '../../styles/components';
1515
import { QrIcon, ShareAndroidIcon, TransferIcon } from '../../styles/icons';
1616
import { BodyM, Display } from '../../styles/text';
@@ -21,6 +21,7 @@ const Funding = ({
2121
}: TransferScreenProps<'Funding'>): ReactElement => {
2222
const { t } = useTranslation('lightning');
2323
const { onchainBalance } = useBalance();
24+
const receiveSheetRef = useSheetRef('receive');
2425
const isGeoBlocked = useAppSelector(isGeoBlockedSelector);
2526
const spendingIntroSeen = useAppSelector(spendingIntroSeenSelector);
2627

@@ -34,7 +35,7 @@ const Funding = ({
3435

3536
const onFund = (): void => {
3637
navigation.popTo('Wallet', { screen: 'Home' });
37-
showSheet('receive', { screen: 'ReceiveAmount' });
38+
receiveSheetRef.current?.present({ screen: 'ReceiveAmount' });
3839
};
3940

4041
const onAdvanced = (): void => {

0 commit comments

Comments
 (0)