()
| 13 | const requiresWalletExportIsSaved = ['ReceiveDetails', 'WalletAddresses']; |
| 14 | |
| 15 | export 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 | }); |
no test coverage detected