REF: send/receive btns

This commit is contained in:
Overtorment 2018-07-07 12:30:50 +01:00
parent 8fbd2c6ad1
commit a5862cb76e
2 changed files with 32 additions and 5 deletions

View File

@ -30,6 +30,14 @@ export class AbstractWallet {
return this.balance;
}
allowReceive() {
return true;
}
allowSend() {
return this.getBalance() > 0;
}
/**
* Returns delta of unconfirmed balance. For example, if theres no
* unconfirmed balance its 0

View File

@ -79,11 +79,20 @@ export default class WalletsList extends Component {
}
setTimeout(() => {
let showSend = false;
let showReceive = false;
let wallets = BlueApp.getWallets();
let wallet = wallets[this.lastSnappedTo || 0];
if (wallet) {
showSend = wallet.allowSend();
showReceive = wallet.allowReceive();
}
this.setState({
isLoading: false,
isTransactionsLoading: false,
showReceiveButton: (BlueApp.getWallets().length > 0 && true) || false,
showSendButton: (BlueApp.getWallets().length > 0 && true) || false,
showReceiveButton: showReceive,
showSendButton: showSend,
showRereshButton: (BlueApp.getWallets().length > 0 && true) || false,
dataSource: ds.cloneWithRows(
BlueApp.getTransactions(this.lastSnappedTo || 0),
@ -126,11 +135,21 @@ export default class WalletsList extends Component {
if (index < BlueApp.getWallets().length) {
// do not show for last card
let showSend = false;
let showReceive = false;
let wallets = BlueApp.getWallets();
let wallet = wallets[this.lastSnappedTo || 0];
if (wallet) {
showSend = wallet.allowSend();
showReceive = wallet.allowReceive();
}
setTimeout(
() =>
this.setState({
showReceiveButton: true,
showSendButton: true,
showReceiveButton: showReceive,
showSendButton: showSend,
showRereshButton: true,
}),
50,
@ -375,7 +394,7 @@ export default class WalletsList extends Component {
})()}
{(() => {
if (this.state.showReceiveButton) {
if (this.state.showSendButton) {
return (
<BlueSendButtonIcon
onPress={() => {