/* eslint-disable react/prop-types */ import React, { useEffect, useState } from 'react'; import { View, ActivityIndicator, Image, Text, TouchableOpacity, FlatList, StyleSheet } from 'react-native'; import { SafeBlueArea, BlueNavigationStyle, BlueText, BlueSpacing20, BluePrivateBalance } from '../../BlueComponents'; import LinearGradient from 'react-native-linear-gradient'; import { LightningCustodianWallet } from '../../class/wallets/lightning-custodian-wallet'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; import WalletGradient from '../../class/wallet-gradient'; import { useRoute } from '@react-navigation/native'; /** @type {AppStorage} */ const BlueApp = require('../../BlueApp'); const loc = require('../../loc'); const styles = StyleSheet.create({ root: { flex: 1, }, loading: { flex: 1, justifyContent: 'center', alignContent: 'center', paddingTop: 20, }, itemRoot: { backgroundColor: 'transparent', padding: 10, marginVertical: 17, }, gradient: { padding: 15, borderRadius: 10, minHeight: 164, elevation: 5, }, image: { width: 99, height: 94, position: 'absolute', bottom: 0, right: 0, }, transparentText: { backgroundColor: 'transparent', }, label: { backgroundColor: 'transparent', fontSize: 19, color: '#fff', }, balance: { backgroundColor: 'transparent', fontWeight: 'bold', fontSize: 36, color: '#fff', }, latestTxLabel: { backgroundColor: 'transparent', fontSize: 13, color: '#fff', }, latestTxValue: { backgroundColor: 'transparent', fontWeight: 'bold', fontSize: 16, color: '#fff', }, noWallets: { flex: 1, justifyContent: 'center', alignItems: 'center', paddingTop: 20, }, center: { textAlign: 'center', }, }); const SelectWallet = () => { const { chainType, onWalletSelect, availableWallets } = useRoute().params; const [isLoading, setIsLoading] = useState(true); let data = chainType ? BlueApp.getWallets().filter(item => item.chain === chainType && item.allowSend()) : BlueApp.getWallets().filter(item => item.allowSend()) || []; if (availableWallets && availableWallets.length > 0) { // availableWallets if provided, overrides chainType argument and `allowSend()` check data = availableWallets; } useEffect(() => { setIsLoading(false); }, []); const renderItem = ({ item }) => { return ( { ReactNativeHapticFeedback.trigger('selection', { ignoreAndroidSystemSettings: false }); onWalletSelect(item); }} > {item.getLabel()} {item.hideBalance ? ( ) : ( {loc.formatBalance(Number(item.getBalance()), item.getPreferredBalanceUnit(), true)} )} {loc.wallets.list.latest_transaction} {loc.transactionTimeToReadable(item.getLatestTransactionTime())} ); }; if (isLoading) { return ( ); } else if (data.length <= 0) { return ( There are currently no Bitcoin wallets available. A Bitcoin wallet is required to refill Lightning wallets. Please, create or import one. ); } else { return ( `${index}`} /> ); } }; SelectWallet.navigationOptions = ({ navigation }) => ({ ...BlueNavigationStyle(navigation, true, () => navigation.goBack(null)), title: loc.wallets.select_wallet, }); export default SelectWallet;