2018-10-09 06:25:36 +02:00
|
|
|
import React, { Component } from 'react';
|
2019-02-19 21:32:45 +01:00
|
|
|
import {
|
|
|
|
Text,
|
|
|
|
View,
|
|
|
|
ActivityIndicator,
|
|
|
|
InteractionManager,
|
|
|
|
Image,
|
|
|
|
FlatList,
|
|
|
|
RefreshControl,
|
|
|
|
TouchableOpacity,
|
|
|
|
StatusBar,
|
2019-02-23 16:48:20 +01:00
|
|
|
Platform,
|
|
|
|
Clipboard,
|
2019-02-19 21:32:45 +01:00
|
|
|
} from 'react-native';
|
2018-12-11 23:52:46 +01:00
|
|
|
import LinearGradient from 'react-native-linear-gradient';
|
2018-10-09 06:25:36 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2018-12-11 23:52:46 +01:00
|
|
|
import { NavigationEvents } from 'react-navigation';
|
2019-02-19 01:37:34 +01:00
|
|
|
import { BlueSendButtonIcon, BlueReceiveButtonIcon, BlueTransactionListItem } from '../../BlueComponents';
|
2018-10-09 06:25:36 +02:00
|
|
|
import { Icon } from 'react-native-elements';
|
2018-10-20 23:10:21 +02:00
|
|
|
import { BitcoinUnit } from '../../models/bitcoinUnits';
|
2018-12-22 04:23:52 +01:00
|
|
|
import { LightningCustodianWallet } from '../../class';
|
2019-01-26 00:32:35 +01:00
|
|
|
import WalletGradient from '../../class/walletGradient';
|
2019-02-23 16:48:20 +01:00
|
|
|
import ToolTip from 'react-native-tooltip';
|
|
|
|
import showPopupMenu from 'react-native-popup-menu-android';
|
2018-10-09 06:25:36 +02:00
|
|
|
/** @type {AppStorage} */
|
|
|
|
let BlueApp = require('../../BlueApp');
|
|
|
|
let loc = require('../../loc');
|
|
|
|
let EV = require('../../events');
|
|
|
|
|
|
|
|
export default class WalletTransactions extends Component {
|
|
|
|
static navigationOptions = ({ navigation }) => {
|
|
|
|
return {
|
|
|
|
headerRight: (
|
2018-11-02 14:53:35 +01:00
|
|
|
<TouchableOpacity
|
2019-02-19 01:03:32 +01:00
|
|
|
style={{ marginHorizontal: 16, minWidth: 150, justifyContent: 'center', alignItems: 'flex-end' }}
|
2018-10-09 06:25:36 +02:00
|
|
|
onPress={() =>
|
|
|
|
navigation.navigate('WalletDetails', {
|
2019-01-07 05:54:22 +01:00
|
|
|
wallet: navigation.state.params.wallet,
|
2018-10-09 06:25:36 +02:00
|
|
|
})
|
|
|
|
}
|
2018-11-02 14:53:35 +01:00
|
|
|
>
|
2019-02-19 01:03:32 +01:00
|
|
|
<Icon name="kebab-horizontal" size={22} type="octicon" color="#FFFFFF" />
|
2018-11-02 14:53:35 +01:00
|
|
|
</TouchableOpacity>
|
2018-10-09 06:25:36 +02:00
|
|
|
),
|
|
|
|
headerStyle: {
|
2019-01-26 00:32:35 +01:00
|
|
|
backgroundColor: navigation.getParam('headerColor'),
|
2018-10-09 06:25:36 +02:00
|
|
|
borderBottomWidth: 0,
|
2018-11-02 14:53:35 +01:00
|
|
|
elevation: 0,
|
|
|
|
shadowRadius: 0,
|
2018-10-09 06:25:36 +02:00
|
|
|
},
|
|
|
|
headerTintColor: '#FFFFFF',
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-02-23 16:48:20 +01:00
|
|
|
walletBalanceText = null;
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2018-12-11 23:52:46 +01:00
|
|
|
|
|
|
|
// here, when we receive REMOTE_TRANSACTIONS_COUNT_CHANGED we fetch TXs and balance for current wallet
|
|
|
|
EV(EV.enum.REMOTE_TRANSACTIONS_COUNT_CHANGED, this.refreshTransactionsFunction.bind(this));
|
|
|
|
const wallet = props.navigation.getParam('wallet');
|
|
|
|
this.props.navigation.setParams({ wallet: wallet });
|
2018-10-09 06:25:36 +02:00
|
|
|
this.state = {
|
|
|
|
isLoading: true,
|
2019-02-17 02:22:14 +01:00
|
|
|
showShowFlatListRefreshControl: false,
|
2018-12-11 23:52:46 +01:00
|
|
|
wallet: wallet,
|
2019-02-19 00:37:53 +01:00
|
|
|
dataSource: this.getTransactions(15),
|
|
|
|
limit: 15,
|
|
|
|
pageSize: 20,
|
2018-12-22 04:23:52 +01:00
|
|
|
walletPreviousPreferredUnit: wallet.getPreferredBalanceUnit(),
|
2018-10-09 06:25:36 +02:00
|
|
|
};
|
2018-12-11 23:52:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2019-02-17 02:22:14 +01:00
|
|
|
// nop
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forcefully fetches TXs and balance for wallet
|
|
|
|
*/
|
|
|
|
refreshTransactionsFunction() {
|
|
|
|
let that = this;
|
|
|
|
setTimeout(function() {
|
|
|
|
that.refreshTransactions();
|
|
|
|
}, 4000); // giving a chance to remote server to propagate
|
|
|
|
}
|
|
|
|
|
2019-02-19 00:37:53 +01:00
|
|
|
/**
|
|
|
|
* Simple wrapper for `wallet.getTransactions()`, where `wallet` is current wallet.
|
|
|
|
* Sorts. Provides limiting.
|
|
|
|
*
|
|
|
|
* @param limit {Integer} How many txs return, starting from the earliest. Default: all of them.
|
|
|
|
* @returns {Array}
|
|
|
|
*/
|
|
|
|
getTransactions(limit = Infinity) {
|
|
|
|
let wallet = this.props.navigation.getParam('wallet');
|
|
|
|
let txs = wallet.getTransactions();
|
|
|
|
for (let tx of txs) {
|
|
|
|
tx.sort_ts = +new Date(tx.received);
|
|
|
|
}
|
|
|
|
txs = txs.sort(function(a, b) {
|
|
|
|
return b.sort_ts - a.sort_ts;
|
|
|
|
});
|
|
|
|
return txs.slice(0, limit);
|
|
|
|
}
|
|
|
|
|
2019-02-17 02:22:14 +01:00
|
|
|
redrawScreen() {
|
|
|
|
InteractionManager.runAfterInteractions(async () => {
|
|
|
|
console.log('wallets/transactions redrawScreen()');
|
2018-10-09 06:25:36 +02:00
|
|
|
|
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
2019-02-17 02:22:14 +01:00
|
|
|
showShowFlatListRefreshControl: false,
|
2019-02-19 00:37:53 +01:00
|
|
|
dataSource: this.getTransactions(this.state.limit),
|
2018-10-09 06:25:36 +02:00
|
|
|
});
|
2019-02-17 02:22:14 +01:00
|
|
|
});
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isLightning() {
|
|
|
|
let w = this.state.wallet;
|
2018-12-28 16:52:06 +01:00
|
|
|
if (w && w.type === LightningCustodianWallet.type) {
|
2018-10-09 06:25:36 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forcefully fetches TXs and balance for wallet
|
|
|
|
*/
|
|
|
|
refreshTransactions() {
|
2019-02-17 02:22:14 +01:00
|
|
|
if (this.state.isLoading) return;
|
2018-10-09 06:25:36 +02:00
|
|
|
this.setState(
|
|
|
|
{
|
2019-02-17 02:22:14 +01:00
|
|
|
showShowFlatListRefreshControl: true,
|
|
|
|
isLoading: true,
|
2018-10-09 06:25:36 +02:00
|
|
|
},
|
2019-02-17 02:22:14 +01:00
|
|
|
async () => {
|
|
|
|
let noErr = true;
|
|
|
|
let smthChanged = false;
|
|
|
|
try {
|
|
|
|
/** @type {LegacyWallet} */
|
|
|
|
let wallet = this.state.wallet;
|
|
|
|
let balanceStart = +new Date();
|
|
|
|
const oldBalance = wallet.getBalance();
|
|
|
|
await wallet.fetchBalance();
|
|
|
|
if (oldBalance !== wallet.getBalance()) smthChanged = true;
|
|
|
|
let balanceEnd = +new Date();
|
|
|
|
console.log(wallet.getLabel(), 'fetch balance took', (balanceEnd - balanceStart) / 1000, 'sec');
|
|
|
|
let start = +new Date();
|
|
|
|
const oldTxLen = wallet.getTransactions().length;
|
|
|
|
await wallet.fetchTransactions();
|
|
|
|
if (oldTxLen !== wallet.getTransactions().length) smthChanged = true;
|
|
|
|
if (wallet.fetchPendingTransactions) {
|
|
|
|
await wallet.fetchPendingTransactions();
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
2019-02-17 02:22:14 +01:00
|
|
|
if (wallet.fetchUserInvoices) {
|
|
|
|
await wallet.fetchUserInvoices();
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
2019-02-17 02:22:14 +01:00
|
|
|
let end = +new Date();
|
|
|
|
console.log(wallet.getLabel(), 'fetch tx took', (end - start) / 1000, 'sec');
|
|
|
|
} catch (err) {
|
|
|
|
noErr = false;
|
|
|
|
console.warn(err);
|
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
|
|
|
showShowFlatListRefreshControl: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (noErr && smthChanged) {
|
|
|
|
console.log('saving to disk');
|
|
|
|
await BlueApp.saveToDisk(); // caching
|
|
|
|
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED); // let other components know they should redraw
|
|
|
|
}
|
|
|
|
this.redrawScreen();
|
2018-10-09 06:25:36 +02:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-10-20 23:10:21 +02:00
|
|
|
changeWalletBalanceUnit() {
|
2018-12-22 04:23:52 +01:00
|
|
|
let walletPreviousPreferredUnit = this.state.wallet.getPreferredBalanceUnit();
|
|
|
|
const wallet = this.state.wallet;
|
|
|
|
if (walletPreviousPreferredUnit === BitcoinUnit.BTC) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.SATS;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
|
|
|
} else if (walletPreviousPreferredUnit === BitcoinUnit.SATS) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.LOCAL_CURRENCY;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.SATS;
|
|
|
|
} else if (walletPreviousPreferredUnit === BitcoinUnit.LOCAL_CURRENCY) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.BTC;
|
2018-12-22 04:43:49 +01:00
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
2018-12-20 04:03:15 +01:00
|
|
|
} else {
|
2018-12-22 04:23:52 +01:00
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.BTC;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
2018-10-20 23:10:21 +02:00
|
|
|
}
|
2018-12-22 04:23:52 +01:00
|
|
|
|
2018-12-23 14:05:33 +01:00
|
|
|
this.setState({ wallet: wallet, walletPreviousPreferredUnit: walletPreviousPreferredUnit });
|
2018-10-20 23:10:21 +02:00
|
|
|
}
|
|
|
|
|
2019-02-23 16:48:20 +01:00
|
|
|
handleCopyPress = _item => {
|
|
|
|
Clipboard.setString(loc.formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit()).toString());
|
|
|
|
};
|
|
|
|
|
|
|
|
showAndroidTooltip = () => {
|
|
|
|
showPopupMenu(
|
|
|
|
[{ id: loc.transactions.details.copy, label: loc.transactions.details.copy }],
|
|
|
|
this.handleCopyPress,
|
|
|
|
this.walletBalanceText,
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
renderWalletHeader = () => {
|
|
|
|
return (
|
2019-02-19 01:37:34 +01:00
|
|
|
<LinearGradient
|
|
|
|
colors={WalletGradient.gradientsFor(this.state.wallet.type)}
|
|
|
|
style={{ padding: 15, minHeight: 140, justifyContent: 'center' }}
|
|
|
|
>
|
2018-10-09 06:25:36 +02:00
|
|
|
<Image
|
|
|
|
source={
|
2018-12-28 16:52:06 +01:00
|
|
|
(LightningCustodianWallet.type === this.state.wallet.type && require('../../img/lnd-shape.png')) ||
|
2018-10-09 06:25:36 +02:00
|
|
|
require('../../img/btc-shape.png')
|
|
|
|
}
|
|
|
|
style={{
|
|
|
|
width: 99,
|
|
|
|
height: 94,
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 0,
|
|
|
|
right: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Text
|
|
|
|
numberOfLines={1}
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontSize: 19,
|
|
|
|
color: '#fff',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{this.state.wallet.getLabel()}
|
|
|
|
</Text>
|
2019-02-23 16:48:20 +01:00
|
|
|
{Platform.OS === 'ios' && (
|
|
|
|
<ToolTip
|
|
|
|
ref={tooltip => (this.tooltip = tooltip)}
|
|
|
|
actions={[{ text: loc.transactions.details.copy, onPress: this.handleCopyPress }]}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() => this.changeWalletBalanceUnit()}
|
|
|
|
ref={ref => (this.walletBalanceText = ref)}
|
|
|
|
onLongPress={() => (Platform.OS === 'ios' ? this.tooltip.showMenu() : this.showAndroidTooltip())}
|
|
|
|
>
|
2018-10-20 23:10:21 +02:00
|
|
|
<Text
|
|
|
|
numberOfLines={1}
|
|
|
|
adjustsFontSizeToFit
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 36,
|
|
|
|
color: '#fff',
|
|
|
|
}}
|
|
|
|
>
|
2019-01-06 22:23:14 +01:00
|
|
|
{loc.formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit(), true).toString()}
|
2018-10-20 23:10:21 +02:00
|
|
|
</Text>
|
|
|
|
</TouchableOpacity>
|
2019-02-19 01:37:34 +01:00
|
|
|
{this.state.wallet.type === LightningCustodianWallet.type && (
|
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('ManageFunds', { fromWallet: this.state.wallet })}>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
marginTop: 14,
|
|
|
|
marginBottom: 10,
|
|
|
|
backgroundColor: 'rgba(255,255,255,0.2)',
|
|
|
|
borderRadius: 9,
|
|
|
|
minWidth: 119,
|
|
|
|
minHeight: 39,
|
|
|
|
width: 119,
|
|
|
|
height: 39,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontWeight: '500',
|
|
|
|
fontSize: 14,
|
|
|
|
color: '#FFFFFF',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.lnd.title}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
)}
|
2018-10-09 06:25:36 +02:00
|
|
|
</LinearGradient>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-11-01 20:44:39 +01:00
|
|
|
_keyExtractor = (_item, index) => index.toString();
|
2018-10-09 06:25:36 +02:00
|
|
|
|
2019-02-19 21:32:45 +01:00
|
|
|
renderListFooterComponent = () => {
|
|
|
|
// if not all txs rendered - display indicator
|
|
|
|
return (this.getTransactions(Infinity).length > this.state.limit && <ActivityIndicator />) || <View />;
|
|
|
|
};
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
renderListHeaderComponent = () => {
|
|
|
|
return (
|
2019-02-16 07:16:08 +01:00
|
|
|
<View style={{ flex: 1, flexDirection: 'row', height: 50 }}>
|
2018-10-09 06:25:36 +02:00
|
|
|
<Text
|
|
|
|
style={{
|
2019-02-16 07:16:08 +01:00
|
|
|
flex: 1,
|
2018-10-09 06:25:36 +02:00
|
|
|
paddingLeft: 15,
|
|
|
|
paddingTop: 15,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 24,
|
|
|
|
color: BlueApp.settings.foregroundColor,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.transactions.list.title}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-12-23 14:05:33 +01:00
|
|
|
async onWillBlur() {
|
2018-12-28 01:44:41 +01:00
|
|
|
StatusBar.setBarStyle('dark-content');
|
2018-12-23 14:05:33 +01:00
|
|
|
await BlueApp.saveToDisk();
|
|
|
|
}
|
|
|
|
|
2018-12-28 02:32:48 +01:00
|
|
|
componentWillUnmount() {
|
|
|
|
this.onWillBlur();
|
|
|
|
}
|
|
|
|
|
2019-01-30 03:13:45 +01:00
|
|
|
renderItem = item => {
|
|
|
|
return <BlueTransactionListItem item={item.item} itemPriceUnit={this.state.wallet.getPreferredBalanceUnit()} />;
|
2018-12-27 07:12:19 +01:00
|
|
|
};
|
|
|
|
|
2018-10-09 06:25:36 +02:00
|
|
|
render() {
|
|
|
|
const { navigate } = this.props.navigation;
|
|
|
|
return (
|
|
|
|
<View style={{ flex: 1 }}>
|
2018-12-12 04:33:28 +01:00
|
|
|
<NavigationEvents
|
|
|
|
onWillFocus={() => {
|
2018-12-28 01:44:41 +01:00
|
|
|
StatusBar.setBarStyle('light-content');
|
2019-02-17 02:22:14 +01:00
|
|
|
this.redrawScreen();
|
2018-12-12 04:33:28 +01:00
|
|
|
}}
|
2018-12-23 14:05:33 +01:00
|
|
|
onWillBlur={() => this.onWillBlur()}
|
2018-12-12 04:33:28 +01:00
|
|
|
/>
|
2018-10-09 06:25:36 +02:00
|
|
|
{this.renderWalletHeader()}
|
2019-01-12 01:23:32 +01:00
|
|
|
|
2019-02-19 01:37:34 +01:00
|
|
|
<View style={{ flex: 1, backgroundColor: '#FFFFFF' }}>
|
|
|
|
{this.state.wallet.type === LightningCustodianWallet.type && (
|
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() => {
|
|
|
|
console.log('navigating to LappBrowser');
|
|
|
|
navigate('LappBrowser', { fromSecret: this.state.wallet.getSecret(), fromWallet: this.state.wallet });
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
marginVertical: 16,
|
|
|
|
backgroundColor: '#f2f2f2',
|
|
|
|
borderRadius: 9,
|
|
|
|
minWidth: 343,
|
|
|
|
minHeight: 49,
|
|
|
|
width: 343,
|
|
|
|
height: 49,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
alignSelf: 'center',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Text>marketplace</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
)}
|
2018-11-01 20:44:39 +01:00
|
|
|
<FlatList
|
2019-02-19 00:37:53 +01:00
|
|
|
onEndReachedThreshold={0.3}
|
|
|
|
onEndReached={() => {
|
|
|
|
// pagination in works. in this block we will add more txs to flatlist
|
|
|
|
// so as user scrolls closer to bottom it will render mode transactions
|
|
|
|
|
|
|
|
if (this.getTransactions(Infinity).length < this.state.limit) {
|
2019-02-19 21:32:45 +01:00
|
|
|
// all list rendered. nop
|
2019-02-19 00:37:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
dataSource: this.getTransactions(this.state.limit + this.state.pageSize),
|
|
|
|
limit: this.state.limit + this.state.pageSize,
|
|
|
|
pageSize: this.state.pageSize * 2,
|
|
|
|
});
|
|
|
|
}}
|
2018-11-01 20:44:39 +01:00
|
|
|
ListHeaderComponent={this.renderListHeaderComponent}
|
2019-02-19 21:32:45 +01:00
|
|
|
ListFooterComponent={this.renderListFooterComponent}
|
2018-11-01 20:44:39 +01:00
|
|
|
ListEmptyComponent={
|
2019-01-30 22:47:40 +01:00
|
|
|
<View style={{ top: 50, minHeight: 200, paddingHorizontal: 16 }}>
|
2018-11-01 20:44:39 +01:00
|
|
|
<Text
|
2019-01-30 22:53:29 +01:00
|
|
|
numberOfLines={0}
|
2018-11-01 20:44:39 +01:00
|
|
|
style={{
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{(this.isLightning() &&
|
2019-01-30 22:47:40 +01:00
|
|
|
'Lightning wallet should be used for your daily transactions. Fees are unfairly cheap and speed is blazing fast.') ||
|
2018-11-01 20:44:39 +01:00
|
|
|
loc.wallets.list.empty_txs1}
|
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
|
|
|
}}
|
|
|
|
>
|
2019-01-30 22:47:40 +01:00
|
|
|
{(this.isLightning() && '\nTo start using it tap on "manage funds" and topup your balance') ||
|
2018-11-01 20:44:39 +01:00
|
|
|
loc.wallets.list.empty_txs2}
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
<Text />
|
|
|
|
<Text />
|
|
|
|
|
|
|
|
{!this.isLightning() && (
|
2018-10-10 21:36:32 +02:00
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontSize: 18,
|
|
|
|
color: '#9aa0aa',
|
|
|
|
textAlign: 'center',
|
2018-11-01 20:44:39 +01:00
|
|
|
textDecorationLine: 'underline',
|
2018-10-10 21:36:32 +02:00
|
|
|
}}
|
2018-11-01 20:44:39 +01:00
|
|
|
onPress={() =>
|
|
|
|
this.props.navigation.navigate('BuyBitcoin', {
|
|
|
|
address: this.state.wallet.getAddress(),
|
|
|
|
secret: this.state.wallet.getSecret(),
|
|
|
|
})
|
|
|
|
}
|
2018-10-10 21:36:32 +02:00
|
|
|
>
|
2018-11-01 20:44:39 +01:00
|
|
|
{loc.wallets.list.tap_here_to_buy}
|
2018-10-10 21:36:32 +02:00
|
|
|
</Text>
|
2018-11-01 20:44:39 +01:00
|
|
|
)}
|
|
|
|
</View>
|
|
|
|
}
|
2019-02-17 02:22:14 +01:00
|
|
|
refreshControl={
|
|
|
|
<RefreshControl onRefresh={() => this.refreshTransactions()} refreshing={this.state.showShowFlatListRefreshControl} />
|
|
|
|
}
|
2018-11-01 20:44:39 +01:00
|
|
|
data={this.state.dataSource}
|
|
|
|
keyExtractor={this._keyExtractor}
|
2019-01-30 03:13:45 +01:00
|
|
|
renderItem={this.renderItem}
|
2018-11-01 20:44:39 +01:00
|
|
|
/>
|
2018-10-09 06:25:36 +02:00
|
|
|
</View>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignSelf: 'center',
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 30,
|
2019-01-05 03:14:23 +01:00
|
|
|
borderRadius: 30,
|
|
|
|
minHeight: 48,
|
2019-01-05 03:46:10 +01:00
|
|
|
flex: 0.84,
|
2018-10-09 06:25:36 +02:00
|
|
|
overflow: 'hidden',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{(() => {
|
2019-02-19 01:37:34 +01:00
|
|
|
if (this.state.wallet.allowReceive()) {
|
2018-10-09 06:25:36 +02:00
|
|
|
return (
|
|
|
|
<BlueReceiveButtonIcon
|
|
|
|
onPress={() => {
|
2019-02-19 01:37:34 +01:00
|
|
|
if (this.state.wallet.type === LightningCustodianWallet.type) {
|
2018-12-25 17:34:51 +01:00
|
|
|
navigate('LNDCreateInvoice', { fromWallet: this.state.wallet });
|
|
|
|
} else {
|
|
|
|
navigate('ReceiveDetails', { address: this.state.wallet.getAddress(), secret: this.state.wallet.getSecret() });
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
|
|
|
|
{(() => {
|
2019-02-19 01:37:34 +01:00
|
|
|
if (this.state.wallet.allowSend()) {
|
2018-10-09 06:25:36 +02:00
|
|
|
return (
|
|
|
|
<BlueSendButtonIcon
|
|
|
|
onPress={() => {
|
2018-12-28 16:52:06 +01:00
|
|
|
if (this.state.wallet.type === LightningCustodianWallet.type) {
|
2018-10-09 06:25:36 +02:00
|
|
|
navigate('ScanLndInvoice', { fromSecret: this.state.wallet.getSecret() });
|
|
|
|
} else {
|
2019-02-24 20:49:04 +01:00
|
|
|
navigate('SendDetails', {
|
|
|
|
fromAddress: this.state.wallet.getAddress(),
|
|
|
|
fromSecret: this.state.wallet.getSecret(),
|
|
|
|
fromWallet: this.state.wallet,
|
|
|
|
});
|
2018-10-09 06:25:36 +02:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})()}
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WalletTransactions.propTypes = {
|
|
|
|
navigation: PropTypes.shape({
|
|
|
|
navigate: PropTypes.func,
|
|
|
|
goBack: PropTypes.func,
|
|
|
|
getParam: PropTypes.func,
|
|
|
|
setParams: PropTypes.func,
|
|
|
|
}),
|
|
|
|
};
|