import { useTheme } from '@react-navigation/native'; import React, { useState } from 'react'; import { Keyboard, KeyboardAvoidingView, Platform, StyleSheet, TextInput, View } from 'react-native'; import { generateChecksumWords } from '../../blue_modules/checksumWords'; import { BlueCard, BlueSpacing10, BlueSpacing20, BlueText } from '../../BlueComponents'; import { randomBytes } from '../../class/rng'; import Button from '../../components/Button'; import navigationStyle from '../../components/navigationStyle'; import SafeArea from '../../components/SafeArea'; import loc from '../../loc'; const GenerateWord = () => { const { colors } = useTheme(); const [mnemonic, setMnemonic] = useState(''); const [result, setResult] = useState(''); const stylesHooks = StyleSheet.create({ input: { borderColor: colors.formBorder, borderBottomColor: colors.formBorder, backgroundColor: colors.inputBackgroundColor, }, }); const handleUpdateMnemonic = nextValue => { setMnemonic(nextValue); setResult(); }; const checkMnemonic = async () => { Keyboard.dismiss(); const seedPhrase = mnemonic.toString(); const possibleWords = generateChecksumWords(seedPhrase); if (!possibleWords) { // likely because of an invalid mnemonic setResult(loc.autofill_word.error); return; } const random = await randomBytes(1); const randomindex = Math.round((random.readUInt8(0) / 255) * (possibleWords.length - 1)); setResult(possibleWords[randomindex]); }; const clearMnemonicInput = () => { setMnemonic(''); setResult(); }; return (