import React, { useCallback, useEffect } from 'react'; import { useNavigation, useRoute } from '@react-navigation/native'; import { BackHandler, I18nManager, ScrollView, StyleSheet, Text, View } from 'react-native'; import Button from '../../components/Button'; import { useTheme } from '../../components/themes'; import { disallowScreenshot } from 'react-native-screen-capture'; import loc from '../../loc'; import { useStorage } from '../../hooks/context/useStorage'; import { useSettings } from '../../hooks/context/useSettings'; const PleaseBackup: React.FC = () => { const { wallets } = useStorage(); const { walletID } = useRoute().params as { walletID: string }; 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()}