import React, { useEffect, useState, useCallback, useContext } from 'react'; import { ActivityIndicator, View, BackHandler, Text, ScrollView, StyleSheet, I18nManager } from 'react-native'; import { useNavigation, useRoute } from '@react-navigation/native'; import navigationStyle from '../../components/navigationStyle'; import Privacy from '../../blue_modules/Privacy'; import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import { AbstractWallet } from '../../class'; import { useTheme } from '../../components/themes'; import Button from '../../components/Button'; import SafeArea from '../../components/SafeArea'; const PleaseBackup: React.FC = () => { const { wallets } = useContext(BlueStorageContext); const [isLoading, setIsLoading] = useState(true); const { walletID } = useRoute().params as { walletID: string }; const wallet = wallets.find((w: AbstractWallet) => w.getID() === walletID); const navigation = useNavigation(); 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(() => { Privacy.enableBlur(); setIsLoading(false); BackHandler.addEventListener('hardwareBackPress', handleBackButton); return () => { Privacy.disableBlur(); BackHandler.removeEventListener('hardwareBackPress', handleBackButton); }; // 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 ( {isLoading ? ( ) : ( {loc.pleasebackup.text} {renderSecret()}