import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import React, { useCallback, useEffect } from 'react'; import { BackHandler, I18nManager, ScrollView, StyleSheet, Text, View } from 'react-native'; import { disallowScreenshot } from 'react-native-screen-capture'; import Button from '../../components/Button'; import { useTheme } from '../../components/themes'; import { useSettings } from '../../hooks/context/useSettings'; import { useStorage } from '../../hooks/context/useStorage'; import loc from '../../loc'; import { AddWalletStackParamList } from '../../navigation/AddWalletStack'; type RouteProps = RouteProp; type NavigationProp = NativeStackNavigationProp; const PleaseBackup: React.FC = () => { const { wallets } = useStorage(); const { walletID } = useRoute().params; const wallet = wallets.find(w => w.getID() === walletID); const navigation = useNavigation(); const { isPrivacyBlurEnabled } = useSettings(); const { colors } = useTheme(); const stylesHook = StyleSheet.create({ flex: { backgroundColor: colors.elevated, }, word: { backgroundColor: colors.inputBackgroundColor, }, wortText: { color: colors.labelText, }, pleaseText: { color: colors.foregroundColor, }, }); const handleBackButton = useCallback(() => { // @ts-ignore: Ignore navigation.getParent()?.pop(); return true; }, [navigation]); useEffect(() => { BackHandler.addEventListener('hardwareBackPress', handleBackButton); disallowScreenshot(isPrivacyBlurEnabled); return () => { BackHandler.removeEventListener('hardwareBackPress', handleBackButton); disallowScreenshot(false); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const renderSecret = () => { const component: JSX.Element[] = []; const entries = wallet?.getSecret().split(/\s/).entries(); if (entries) { for (const [index, secret] of entries) { if (secret) { const text = `${index + 1}. ${secret} `; component.push( {text} , ); } } } return component; }; return ( {loc.pleasebackup.text} {renderSecret()}