Browse Source

REF: send/receive btns

localNotifications
Overtorment 6 years ago
parent
commit
a5862cb76e
  1. 8
      class/abstract-wallet.js
  2. 29
      screen/wallets/list.js

8
class/abstract-wallet.js

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

29
screen/wallets/list.js

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

Loading…
Cancel
Save