MCPcopy
hub / github.com/BlueWallet/BlueWallet / useExtendedNavigation

Function useExtendedNavigation

hooks/useExtendedNavigation.ts:15–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13const requiresWalletExportIsSaved = ['ReceiveDetails', 'WalletAddresses'];
14
15export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>(): T & {
16 navigateToWalletsList: () => void;
17} => {
18 const originalNavigation = useNavigation<T>();
19 const { wallets, saveToDisk } = useStorage();
20 const { isBiometricUseEnabled } = useBiometrics();
21
22 const enhancedNavigate = useCallback(
23 (
24 ...args:
25 | [string]
26 | [string, object | undefined]
27 | [string, object | undefined, { merge?: boolean }]
28 | [{ name: string; params?: object; path?: string; merge?: boolean }]
29 ) => {
30 let screenOrOptions: any;
31 let params: any;
32 let options: { merge?: boolean } | undefined;
33
34 if (typeof args[0] === 'string') {
35 screenOrOptions = args[0];
36 params = args[1];
37 options = args[2];
38 } else {
39 screenOrOptions = args[0];
40 }
41 let screenName: string;
42 if (typeof screenOrOptions === 'string') {
43 screenName = screenOrOptions;
44 } else if (typeof screenOrOptions === 'object' && 'name' in screenOrOptions) {
45 screenName = screenOrOptions.name;
46 params = screenOrOptions.params; // Assign params from object if present
47 } else {
48 throw new Error('Invalid navigation options');
49 }
50
51 const isRequiresBiometrics = requiresBiometrics.includes(screenName);
52 const isRequiresWalletExportIsSaved = requiresWalletExportIsSaved.includes(screenName);
53
54 const proceedWithNavigation = () => {
55 console.log('Proceeding with navigation to', screenName);
56
57 // Navigation logic based on current route and target screen
58 if (navigationRef.current?.isReady()) {
59 // Get the current route - we need to know which navigator we're in
60 const currentRoute = navigationRef.current.getCurrentRoute();
61 const currentRouteName = currentRoute?.name;
62
63 // Handle specific cases for nested navigation
64 if (currentRouteName === 'DrawerRoot') {
65 // If we're in DrawerRoot and trying to navigate to a screen that exists in DetailViewStackScreensStack
66 originalNavigation.navigate('DrawerRoot', {
67 screen: 'DetailViewStackScreensStack',
68 params: {
69 screen: screenName,
70 params,
71 },
72 });

Callers 15

AddWalletButtonFunction · 0.90
AddressItemFunction · 0.90
SettingsButtonFunction · 0.90
PlausibleDeniabilityFunction · 0.90
AztecoRedeemFunction · 0.90
ReceiveDetailsFunction · 0.90
ScanLNDInvoiceFunction · 0.90
LnurlPaySuccessFunction · 0.90
LnurlPayFunction · 0.90
LNDCreateInvoiceFunction · 0.90
LNDViewInvoiceFunction · 0.90

Calls 10

useStorageFunction · 0.90
useBiometricsFunction · 0.90
unlockWithBiometricsFunction · 0.90
proceedWithNavigationFunction · 0.85
getUserHasSavedExportMethod · 0.80
setUserHasSavedExportMethod · 0.80
errorMethod · 0.45
getIDMethod · 0.45

Tested by

no test coverage detected