|
|
@ -13,7 +13,7 @@ import { |
|
|
|
import LinearGradient from 'react-native-linear-gradient'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import { NavigationEvents } from 'react-navigation'; |
|
|
|
import { BlueText, ManageFundsBigButton, BlueSendButtonIcon, BlueReceiveButtonIcon, BlueTransactionListItem } from '../../BlueComponents'; |
|
|
|
import { BlueSendButtonIcon, BlueReceiveButtonIcon, BlueTransactionListItem } from '../../BlueComponents'; |
|
|
|
import { Icon } from 'react-native-elements'; |
|
|
|
import { BitcoinUnit } from '../../models/bitcoinUnits'; |
|
|
|
import { LightningCustodianWallet } from '../../class'; |
|
|
@ -28,14 +28,14 @@ export default class WalletTransactions extends Component { |
|
|
|
return { |
|
|
|
headerRight: ( |
|
|
|
<TouchableOpacity |
|
|
|
style={{ marginHorizontal: 8, minWidth: 150 }} |
|
|
|
style={{ marginHorizontal: 16, minWidth: 150, justifyContent: 'center', alignItems: 'flex-end' }} |
|
|
|
onPress={() => |
|
|
|
navigation.navigate('WalletDetails', { |
|
|
|
wallet: navigation.state.params.wallet, |
|
|
|
}) |
|
|
|
} |
|
|
|
> |
|
|
|
<Text style={{ color: '#fff', fontSize: 20, fontWeight: '500', textAlign: 'right' }}>{loc.wallets.options}</Text> |
|
|
|
<Icon name="kebab-horizontal" size={22} type="octicon" color="#FFFFFF" /> |
|
|
|
</TouchableOpacity> |
|
|
|
), |
|
|
|
headerStyle: { |
|
|
@ -63,11 +63,6 @@ export default class WalletTransactions extends Component { |
|
|
|
limit: 15, |
|
|
|
pageSize: 20, |
|
|
|
walletPreviousPreferredUnit: wallet.getPreferredBalanceUnit(), |
|
|
|
walletHeaderLatestTransaction: '...', |
|
|
|
showSendButton: |
|
|
|
(wallet.allowSend() && wallet.type === LightningCustodianWallet.type && wallet.balance > 0) || |
|
|
|
(wallet.allowSend() && wallet.type !== LightningCustodianWallet.type), |
|
|
|
showReceiveButton: wallet.allowReceive(), |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
@ -107,33 +102,11 @@ export default class WalletTransactions extends Component { |
|
|
|
redrawScreen() { |
|
|
|
InteractionManager.runAfterInteractions(async () => { |
|
|
|
console.log('wallets/transactions redrawScreen()'); |
|
|
|
let showSend = false; |
|
|
|
let showReceive = false; |
|
|
|
const wallet = this.state.wallet; |
|
|
|
if (wallet) { |
|
|
|
showSend = wallet.allowSend(); |
|
|
|
showReceive = wallet.allowReceive(); |
|
|
|
} |
|
|
|
let showManageFundsBigButton = false; |
|
|
|
let showManageFundsSmallButton = false; |
|
|
|
if (wallet && wallet.type === LightningCustodianWallet.type && wallet.getBalance() * 1 <= 0) { |
|
|
|
showManageFundsBigButton = true; |
|
|
|
showManageFundsSmallButton = false; |
|
|
|
} else if (wallet && wallet.type === LightningCustodianWallet.type && wallet.getBalance() > 0) { |
|
|
|
showManageFundsSmallButton = true; |
|
|
|
showManageFundsBigButton = false; |
|
|
|
} |
|
|
|
|
|
|
|
const latestTXTime = loc.transactionTimeToReadable(wallet.getLatestTransactionTime()); |
|
|
|
this.setState({ |
|
|
|
isLoading: false, |
|
|
|
showShowFlatListRefreshControl: false, |
|
|
|
showReceiveButton: showReceive, |
|
|
|
showSendButton: showSend, |
|
|
|
showManageFundsBigButton, |
|
|
|
showManageFundsSmallButton, |
|
|
|
dataSource: this.getTransactions(this.state.limit), |
|
|
|
walletHeaderLatestTransaction: latestTXTime, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
@ -221,7 +194,10 @@ export default class WalletTransactions extends Component { |
|
|
|
|
|
|
|
renderWalletHeader = () => { |
|
|
|
return ( |
|
|
|
<LinearGradient colors={WalletGradient.gradientsFor(this.state.wallet.type)} style={{ padding: 15, minHeight: 164 }}> |
|
|
|
<LinearGradient |
|
|
|
colors={WalletGradient.gradientsFor(this.state.wallet.type)} |
|
|
|
style={{ padding: 15, minHeight: 140, justifyContent: 'center' }} |
|
|
|
> |
|
|
|
<Image |
|
|
|
source={ |
|
|
|
(LightningCustodianWallet.type === this.state.wallet.type && require('../../img/lnd-shape.png')) || |
|
|
@ -236,7 +212,6 @@ export default class WalletTransactions extends Component { |
|
|
|
}} |
|
|
|
/> |
|
|
|
|
|
|
|
<Text style={{ backgroundColor: 'transparent' }} /> |
|
|
|
<Text |
|
|
|
numberOfLines={1} |
|
|
|
style={{ |
|
|
@ -261,28 +236,34 @@ export default class WalletTransactions extends Component { |
|
|
|
{loc.formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit(), true).toString()} |
|
|
|
</Text> |
|
|
|
</TouchableOpacity> |
|
|
|
<Text style={{ backgroundColor: 'transparent' }} /> |
|
|
|
<Text |
|
|
|
numberOfLines={1} |
|
|
|
style={{ |
|
|
|
backgroundColor: 'transparent', |
|
|
|
fontSize: 13, |
|
|
|
color: '#fff', |
|
|
|
}} |
|
|
|
> |
|
|
|
{loc.wallets.list.latest_transaction} |
|
|
|
</Text> |
|
|
|
<Text |
|
|
|
numberOfLines={1} |
|
|
|
style={{ |
|
|
|
backgroundColor: 'transparent', |
|
|
|
fontWeight: 'bold', |
|
|
|
fontSize: 16, |
|
|
|
color: '#fff', |
|
|
|
}} |
|
|
|
> |
|
|
|
{this.state.walletHeaderLatestTransaction} |
|
|
|
</Text> |
|
|
|
{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> |
|
|
|
)} |
|
|
|
</LinearGradient> |
|
|
|
); |
|
|
|
}; |
|
|
@ -337,48 +318,33 @@ export default class WalletTransactions extends Component { |
|
|
|
onWillBlur={() => this.onWillBlur()} |
|
|
|
/> |
|
|
|
{this.renderWalletHeader()} |
|
|
|
<View style={{ flex: 1, backgroundColor: '#FFFFFF' }}> |
|
|
|
{(() => { |
|
|
|
if (this.state.showManageFundsSmallButton) { |
|
|
|
return ( |
|
|
|
<View style={{ justifyContent: 'space-between', alignContent: 'center', flexDirection: 'row', marginVertical: 8 }}> |
|
|
|
<TouchableOpacity |
|
|
|
style={{ left: 10, flexDirection: 'row', flex: 1, alignItems: 'center' }} |
|
|
|
onPress={() => { |
|
|
|
console.log('navigating to LappBrowser'); |
|
|
|
navigate('LappBrowser', { fromSecret: this.state.wallet.getSecret(), fromWallet: this.state.wallet }); |
|
|
|
}} |
|
|
|
> |
|
|
|
<BlueText style={{ fontWeight: '600', fontSize: 16 }}>marketplace</BlueText> |
|
|
|
<Icon |
|
|
|
name="shopping-cart" |
|
|
|
type="font-awesome" |
|
|
|
size={14} |
|
|
|
color={BlueApp.settings.foregroundColor} |
|
|
|
iconStyle={{ left: 5, top: 2 }} |
|
|
|
/> |
|
|
|
</TouchableOpacity> |
|
|
|
|
|
|
|
<TouchableOpacity |
|
|
|
style={{ marginRight: 10, flexDirection: 'row', alignItems: 'center' }} |
|
|
|
onPress={() => { |
|
|
|
console.log('navigating to', this.state.wallet.getLabel()); |
|
|
|
navigate('ManageFunds', { fromWallet: this.state.wallet }); |
|
|
|
}} |
|
|
|
> |
|
|
|
<BlueText style={{ fontWeight: '600', fontSize: 16 }}>{loc.lnd.title}</BlueText> |
|
|
|
<Icon |
|
|
|
name="link" |
|
|
|
type="font-awesome" |
|
|
|
size={14} |
|
|
|
color={BlueApp.settings.foregroundColor} |
|
|
|
iconStyle={{ left: 5, top: 2, transform: [{ rotate: '90deg' }] }} |
|
|
|
/> |
|
|
|
</TouchableOpacity> |
|
|
|
</View> |
|
|
|
); |
|
|
|
} |
|
|
|
})()} |
|
|
|
<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> |
|
|
|
)} |
|
|
|
<FlatList |
|
|
|
onEndReachedThreshold={0.3} |
|
|
|
onEndReached={() => { |
|
|
@ -468,11 +434,11 @@ export default class WalletTransactions extends Component { |
|
|
|
}} |
|
|
|
> |
|
|
|
{(() => { |
|
|
|
if (this.state.showReceiveButton) { |
|
|
|
if (this.state.wallet.allowReceive()) { |
|
|
|
return ( |
|
|
|
<BlueReceiveButtonIcon |
|
|
|
onPress={() => { |
|
|
|
if (this.state.wallet.type === new LightningCustodianWallet().type) { |
|
|
|
if (this.state.wallet.type === LightningCustodianWallet.type) { |
|
|
|
navigate('LNDCreateInvoice', { fromWallet: this.state.wallet }); |
|
|
|
} else { |
|
|
|
navigate('ReceiveDetails', { address: this.state.wallet.getAddress(), secret: this.state.wallet.getSecret() }); |
|
|
@ -484,7 +450,7 @@ export default class WalletTransactions extends Component { |
|
|
|
})()} |
|
|
|
|
|
|
|
{(() => { |
|
|
|
if (this.state.showSendButton) { |
|
|
|
if (this.state.wallet.allowSend()) { |
|
|
|
return ( |
|
|
|
<BlueSendButtonIcon |
|
|
|
onPress={() => { |
|
|
@ -498,19 +464,6 @@ export default class WalletTransactions extends Component { |
|
|
|
); |
|
|
|
} |
|
|
|
})()} |
|
|
|
|
|
|
|
{(() => { |
|
|
|
if (this.state.showManageFundsBigButton) { |
|
|
|
return ( |
|
|
|
<ManageFundsBigButton |
|
|
|
onPress={() => { |
|
|
|
console.log('navigating to', this.state.wallet.getLabel()); |
|
|
|
navigate('ManageFunds', { fromWallet: this.state.wallet }); |
|
|
|
}} |
|
|
|
/> |
|
|
|
); |
|
|
|
} |
|
|
|
})()} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
); |
|
|
|