diff --git a/navigation/LazyLoadWalletExportStack.tsx b/navigation/LazyLoadWalletExportStack.tsx index 112fe2c4f..a71ca8bfa 100644 --- a/navigation/LazyLoadWalletExportStack.tsx +++ b/navigation/LazyLoadWalletExportStack.tsx @@ -3,7 +3,7 @@ import React, { lazy, Suspense } from 'react'; import { LazyLoadingIndicator } from './LazyLoadingIndicator'; // Define lazy imports -const WalletExport = lazy(() => import('../screen/wallets/export')); +const WalletExport = lazy(() => import('../screen/wallets/WalletExport')); export const WalletExportComponent = () => ( }> diff --git a/screen/wallets/export.js b/screen/wallets/WalletExport.tsx similarity index 79% rename from screen/wallets/export.js rename to screen/wallets/WalletExport.tsx index ea054ca6e..654a13c1b 100644 --- a/screen/wallets/export.js +++ b/screen/wallets/WalletExport.tsx @@ -1,6 +1,6 @@ -import { useFocusEffect, useNavigation, useRoute } from '@react-navigation/native'; +import { useFocusEffect, useNavigation, useRoute, RouteProp } from '@react-navigation/native'; import React, { useCallback, useEffect, useRef, useState } from 'react'; -import { ActivityIndicator, AppState, InteractionManager, ScrollView, StyleSheet, View } from 'react-native'; +import { ActivityIndicator, AppState, InteractionManager, ScrollView, StyleSheet, View, LayoutChangeEvent } from 'react-native'; import { BlueCard, BlueSpacing20, BlueText } from '../../BlueComponents'; import { LegacyWallet, LightningCustodianWallet, SegwitBech32Wallet, SegwitP2SHWallet, WatchOnlyWallet } from '../../class'; import CopyTextToClipboard from '../../components/CopyTextToClipboard'; @@ -12,10 +12,13 @@ import usePrivacy from '../../hooks/usePrivacy'; import loc from '../../loc'; import { useStorage } from '../../hooks/context/useStorage'; import { HandOffActivityType } from '../../components/types'; +import { WalletExportStackParamList } from '../../navigation/WalletExportStack'; -const WalletExport = () => { +type RouteProps = RouteProp; + +const WalletExport: React.FC = () => { const { wallets, saveToDisk } = useStorage(); - const { walletID } = useRoute().params; + const { walletID } = useRoute().params; const [isLoading, setIsLoading] = useState(true); const { goBack } = useNavigation(); const { colors } = useTheme(); @@ -78,18 +81,15 @@ const WalletExport = () => { ); // for SLIP39 we need to show all shares - let secrets = wallet.getSecret(); - if (typeof secrets === 'string') { - secrets = [secrets]; - } + const secrets: string[] = (typeof wallet.getSecret() === 'string' ? [wallet.getSecret()] : wallet.getSecret()) as string[]; - const onLayout = e => { + const onLayout = (e: LayoutChangeEvent) => { const { height, width } = e.nativeEvent.layout; - setQRCodeSize(height > width ? width - 40 : e.nativeEvent.layout.width / 1.8); + setQRCodeSize(height > width ? width - 40 : width / 1.8); }; return ( - + {wallet.typeReadable} @@ -103,20 +103,18 @@ const WalletExport = () => { {secrets.map(s => ( - - {wallet.type !== WatchOnlyWallet.type && ( - {loc.wallets.warning_do_not_disclose} - )} + + {wallet.type !== WatchOnlyWallet.type && {loc.wallets.warning_do_not_disclose}} {wallet.type === LightningCustodianWallet.type || wallet.type === WatchOnlyWallet.type ? ( - + ) : ( - {wallet.getSecret()} + {s} )} {wallet.type === WatchOnlyWallet.type && ( - + )} ))}