BlueWallet/screen/lnd/lndViewAdditionalInvoiceInformation.js

90 lines
2.6 KiB
JavaScript
Raw Normal View History

/* global alert */
2018-12-29 02:15:59 +01:00
import React, { Component } from 'react';
2019-01-21 14:55:39 +01:00
import { View, Share } from 'react-native';
import {
BlueLoading,
BlueCopyTextToClipboard,
SafeBlueArea,
BlueButton,
BlueNavigationStyle,
BlueText,
BlueSpacing20,
} from '../../BlueComponents';
2018-12-29 02:15:59 +01:00
import PropTypes from 'prop-types';
import { QRCode } from 'react-native-custom-qr-codes';
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
const loc = require('../../loc');
export default class LNDViewAdditionalInvoiceInformation extends Component {
static navigationOptions = ({ navigation }) => ({
...BlueNavigationStyle(),
2018-12-29 19:24:51 +01:00
title: 'Additional Information',
2018-12-29 02:15:59 +01:00
});
state = { walletInfo: undefined };
async componentDidMount() {
const fromWallet = this.props.navigation.getParam('fromWallet');
try {
await fromWallet.fetchInfo();
} catch (_) {
alert('Network error');
return;
}
2018-12-29 02:15:59 +01:00
this.setState({ walletInfo: fromWallet.info_raw, addressText: fromWallet.info_raw.uris[0] });
}
render() {
if (typeof this.state.walletInfo === 'undefined') {
return (
<SafeBlueArea style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<BlueLoading />
</SafeBlueArea>
);
}
2018-12-29 02:15:59 +01:00
return (
<SafeBlueArea style={{ flex: 1 }}>
<View style={{ flex: 1, justifyContent: 'space-between', alignItems: 'center' }}>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 16 }}>
<QRCode
content={this.state.walletInfo.uris[0]}
size={300}
color={BlueApp.settings.foregroundColor}
backgroundColor={BlueApp.settings.brandingColor}
logo={require('../../img/qr-code.png')}
/>
<BlueSpacing20 />
<BlueText>Open direct channel with this node:</BlueText>
2019-01-21 14:55:39 +01:00
<BlueCopyTextToClipboard text={this.state.walletInfo.uris[0]} />
2018-12-29 02:15:59 +01:00
</View>
2019-01-25 19:56:43 +01:00
<View style={{ marginBottom: 25 }}>
2018-12-29 02:15:59 +01:00
<BlueButton
icon={{
name: 'share-alternative',
type: 'entypo',
color: BlueApp.settings.buttonTextColor,
}}
onPress={async () => {
Share.share({
message: this.state.walletInfo.uris[0],
});
}}
title={loc.receive.details.share}
/>
</View>
</View>
</SafeBlueArea>
);
}
}
LNDViewAdditionalInvoiceInformation.propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.func,
getParam: PropTypes.func,
dismiss: PropTypes.func,
2018-12-29 02:15:59 +01:00
}),
};