BlueWallet/screen/lnd/lndViewAdditionalInvoiceInformation.js

122 lines
3.1 KiB
JavaScript
Raw Normal View History

/* global alert */
2018-12-28 20:15:59 -05:00
import React, { Component } from 'react';
import { View, Share, StyleSheet } from 'react-native';
2019-01-21 08:55:39 -05:00
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';
2020-07-20 16:38:46 +03:00
import loc from '../../loc';
2020-07-15 13:32:59 -04:00
import { BlueCurrentTheme } from '../../components/themes';
2018-12-28 20:15:59 -05:00
const styles = StyleSheet.create({
loading: {
flex: 1,
2020-08-04 20:28:37 -04:00
justifyContent: 'space-between',
alignItems: 'center',
2020-07-15 13:32:59 -04:00
backgroundColor: BlueCurrentTheme.colors.elevated,
},
root: {
flex: 1,
2020-07-15 13:32:59 -04:00
backgroundColor: BlueCurrentTheme.colors.elevated,
},
wrapper: {
flex: 1,
2020-08-04 20:28:37 -04:00
justifyContent: 'center',
alignItems: 'center',
},
qrcode: {
justifyContent: 'center',
alignItems: 'center',
2020-08-04 20:28:37 -04:00
marginHorizontal: 16,
2020-08-03 13:26:16 -04:00
borderWidth: 6,
borderRadius: 8,
borderColor: '#FFFFFF',
},
share: {
marginBottom: 25,
},
});
2018-12-28 20:15:59 -05:00
export default class LNDViewAdditionalInvoiceInformation extends Component {
state = { walletInfo: undefined };
async componentDidMount() {
2020-05-27 14:12:17 +03:00
const fromWallet = this.props.route.params.fromWallet;
try {
await fromWallet.fetchInfo();
} catch (_) {
2020-07-20 16:38:46 +03:00
alert(loc.errors.network);
2020-08-04 20:28:37 -04:00
this.props.navigation.goBack();
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={styles.loading}>
2018-12-28 20:15:59 -05:00
<BlueLoading />
</SafeBlueArea>
);
}
2018-12-28 20:15:59 -05:00
return (
<SafeBlueArea style={styles.root}>
<View style={styles.wrapper}>
<View style={styles.qrcode}>
2018-12-28 20:15:59 -05:00
<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}
2020-08-03 13:26:16 -04:00
color="#000000"
2020-07-15 13:32:59 -04:00
logoBackgroundColor={BlueCurrentTheme.colors.brandingColor}
2020-08-03 13:26:16 -04:00
backgroundColor="#FFFFFF"
2018-12-28 20:15:59 -05:00
/>
</View>
2020-08-04 20:28:37 -04:00
<BlueSpacing20 />
<BlueText>{loc.lndViewInvoice.open_direct_channel}</BlueText>
<BlueCopyTextToClipboard text={this.state.walletInfo.uris[0]} />
<View style={styles.share}>
2018-12-28 20:15:59 -05:00
<BlueButton
icon={{
name: 'share-alternative',
type: 'entypo',
2020-07-15 13:32:59 -04:00
color: BlueCurrentTheme.colors.buttonTextColor,
2018-12-28 20:15:59 -05:00
}}
onPress={async () => {
Share.share({
message: this.state.walletInfo.uris[0],
});
}}
2020-07-20 16:38:46 +03:00
title={loc.receive.details_share}
2018-12-28 20:15:59 -05:00
/>
</View>
</View>
</SafeBlueArea>
);
}
}
LNDViewAdditionalInvoiceInformation.propTypes = {
2020-05-27 14:12:17 +03:00
route: PropTypes.shape({
params: PropTypes.object,
2018-12-28 20:15:59 -05:00
}),
2020-08-04 20:28:37 -04:00
navigation: PropTypes.shape({
goBack: PropTypes.func,
}),
2018-12-28 20:15:59 -05:00
};
2020-07-15 13:32:59 -04:00
2020-08-04 20:28:37 -04:00
LNDViewAdditionalInvoiceInformation.navigationOptions = () => ({
2020-07-15 13:32:59 -04:00
...BlueNavigationStyle(),
title: 'Additional Information',
});