import { View } from 'react-native'; import React, { useState } from 'react'; import { Button, List, Text } from 'react-native-paper'; import { useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { AccountsProps, StackParamsList, Account } from '../types'; import { addAccount } from '../utils'; const Accounts: React.FC = ({ network, accounts, updateAccounts, currentIndex, updateIndex, }) => { const navigation = useNavigation>(); const [expanded, setExpanded] = useState(false); const [isAccountCreating, setIsAccountCreating] = useState(false); const handlePress = () => setExpanded(!expanded); const addAccountHandler = async () => { setIsAccountCreating(true); const newAccount = await addAccount(network); setIsAccountCreating(false); newAccount && updateAccounts(newAccount); updateIndex(selectedAccounts[selectedAccounts.length - 1].id + 1); }; let selectedAccounts: Account[] = []; if (network === 'eth') { selectedAccounts = accounts.ethAccounts; } if (network === 'cosmos') { selectedAccounts = accounts.cosmosAccounts; } return ( {selectedAccounts && selectedAccounts.map(account => ( { updateIndex(account.id); setExpanded(false); }} /> ))} Address: {selectedAccounts && selectedAccounts[currentIndex] && selectedAccounts[currentIndex].address} Public Key: {selectedAccounts && selectedAccounts[currentIndex] && selectedAccounts[currentIndex].pubKey} ); }; export default Accounts;