import React, { Component } from 'react';
import { View, ActivityIndicator, Image, Text, TouchableOpacity, FlatList } from 'react-native';
import { SafeBlueArea, BlueNavigationStyle, BlueText, BlueSpacing20 } from '../../BlueComponents';
import LinearGradient from 'react-native-linear-gradient';
import PropTypes from 'prop-types';
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import WalletGradient from '../../class/walletGradient';
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
let loc = require('../../loc');
export default class SelectWallet extends Component {
static navigationOptions = () => ({
...BlueNavigationStyle(),
title: loc.wallets.select_wallet,
});
constructor(props) {
super(props);
this.state = {
isLoading: true,
data: [],
};
}
componentDidMount() {
const wallets = BlueApp.getWallets().filter(item => item.chain === this.props.navigation.getParam('chainType') && item.allowSend());
this.setState({
data: wallets,
isLoading: false,
});
}
_renderItem = ({ item }) => {
return (
{
ReactNativeHapticFeedback.trigger('selection', { ignoreAndroidSystemSettings: false });
this.props.navigation.getParam('onWalletSelect')(item);
}}
>
{item.getLabel()}
{loc.formatBalance(Number(item.getBalance()), item.getPreferredBalanceUnit(), true)}
{loc.wallets.list.latest_transaction}
{loc.transactionTimeToReadable(item.getLatestTransactionTime())}
);
};
render() {
if (this.state.isLoading) {
return (
);
} else if (this.state.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.
);
}
return (
`${index}`}
/>
);
}
}
SelectWallet.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
setParams: PropTypes.func,
dismiss: PropTypes.func,
getParam: PropTypes.func,
}),
};