BlueWallet/screen/lnd/lndViewAdditionalInvoiceInformation.js

91 lines
2.7 KiB
JavaScript
Raw Normal View History

/* global alert */
2018-12-28 20:15:59 -05:00
import React, { Component } from 'react';
2019-01-21 08:55:39 -05:00
import { View, Share } from 'react-native';
import {
BlueLoading,
BlueCopyTextToClipboard,
SafeBlueArea,
BlueButton,
BlueNavigationStyle,
BlueText,
BlueSpacing20,
} from '../../BlueComponents';
2018-12-28 20:15:59 -05:00
import PropTypes from 'prop-types';
2019-02-14 00:15:56 -05:00
import QRCode from 'react-native-qrcode-svg';
2018-12-28 20:15:59 -05:00
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
const loc = require('../../loc');
export default class LNDViewAdditionalInvoiceInformation extends Component {
static navigationOptions = ({ navigation }) => ({
...BlueNavigationStyle(),
2018-12-29 13:24:51 -05:00
title: 'Additional Information',
2018-12-28 20:15:59 -05:00
});
state = { walletInfo: undefined };
async componentDidMount() {
const fromWallet = this.props.navigation.getParam('fromWallet');
try {
await fromWallet.fetchInfo();
} catch (_) {
alert('Network error');
return;
}
2018-12-28 20:15:59 -05: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-28 20:15:59 -05: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
2019-02-14 00:15:56 -05:00
value={this.state.walletInfo.uris[0]}
logo={require('../../img/qr-code.png')}
2018-12-28 20:15:59 -05:00
size={300}
2019-02-14 00:15:56 -05:00
logoSize={90}
2018-12-28 20:15:59 -05:00
color={BlueApp.settings.foregroundColor}
2019-02-14 00:15:56 -05:00
logoBackgroundColor={BlueApp.settings.brandingColor}
2018-12-28 20:15:59 -05:00
/>
<BlueSpacing20 />
2019-05-03 23:58:23 +01:00
<BlueText>{loc.lndViewInvoice.open_direct_channel}</BlueText>
2019-01-21 08:55:39 -05:00
<BlueCopyTextToClipboard text={this.state.walletInfo.uris[0]} />
2018-12-28 20:15:59 -05:00
</View>
2019-01-25 13:56:43 -05:00
<View style={{ marginBottom: 25 }}>
2018-12-28 20:15:59 -05: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-28 20:15:59 -05:00
}),
};