BlueWallet/screen/lnd/lndViewAdditionalInvoiceInformation.js

130 lines
3.2 KiB
JavaScript
Raw Normal View History

/* global alert */
2020-11-28 04:06:37 +01:00
import React, { useContext, useEffect, useState } from 'react';
import { View, Share, StyleSheet } from 'react-native';
2019-01-21 14:55:39 +01:00
import {
BlueLoading,
BlueCopyTextToClipboard,
SafeBlueArea,
BlueButton,
BlueNavigationStyle,
BlueText,
BlueSpacing20,
} from '../../BlueComponents';
2019-02-14 06:15:56 +01:00
import QRCode from 'react-native-qrcode-svg';
2020-07-20 15:38:46 +02:00
import loc from '../../loc';
2020-11-28 04:06:37 +01:00
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
import { BlueStorageContext } from '../../blue_modules/storage-context';
const LNDViewAdditionalInvoiceInformation = () => {
// state = { walletInfo: undefined };
const { walletID } = useRoute().params;
const { wallets } = useContext(BlueStorageContext);
const wallet = wallets.find(w => w.getID() === walletID);
const [walletInfo, setWalletInfo] = useState();
const { colors } = useTheme();
const { goBack } = useNavigation();
const stylesHook = StyleSheet.create({
loading: {
backgroundColor: colors.elevated,
},
root: {
backgroundColor: colors.elevated,
},
});
useEffect(() => {
if (wallet) {
wallet
.fetchInfo()
.then(_ => {
setWalletInfo(wallet.info_raw);
})
.catch(error => {
console.log(error);
alert(loc.errors.network);
goBack();
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [wallet]);
if (walletInfo === undefined) {
return (
<SafeBlueArea style={[styles.loading, stylesHook.loading]}>
<BlueLoading />
</SafeBlueArea>
);
}
return (
<SafeBlueArea style={[styles.root, stylesHook.root]}>
<View style={styles.wrapper}>
<View style={styles.qrcode}>
<QRCode
value={walletInfo.uris[0]}
logo={require('../../img/qr-code.png')}
size={300}
logoSize={90}
color="#000000"
logoBackgroundColor={colors.brandingColor}
backgroundColor="#FFFFFF"
/>
</View>
<BlueSpacing20 />
<BlueText>{loc.lndViewInvoice.open_direct_channel}</BlueText>
<BlueCopyTextToClipboard text={walletInfo.uris[0]} />
<View style={styles.share}>
<BlueButton
icon={{
name: 'share-alternative',
type: 'entypo',
color: colors.buttonTextColor,
}}
onPress={async () => {
Share.share({
message: walletInfo.uris[0],
});
}}
title={loc.receive.details_share}
/>
</View>
</View>
</SafeBlueArea>
);
};
2018-12-29 02:15:59 +01:00
const styles = StyleSheet.create({
loading: {
flex: 1,
2020-08-05 02:28:37 +02:00
justifyContent: 'space-between',
alignItems: 'center',
},
root: {
flex: 1,
},
wrapper: {
flex: 1,
2020-08-05 02:28:37 +02:00
justifyContent: 'center',
alignItems: 'center',
},
qrcode: {
justifyContent: 'center',
alignItems: 'center',
2020-08-05 02:28:37 +02:00
marginHorizontal: 16,
2020-08-03 19:26:16 +02:00
borderWidth: 6,
borderRadius: 8,
borderColor: '#FFFFFF',
},
share: {
marginBottom: 25,
},
});
2020-11-28 04:06:37 +01:00
export default LNDViewAdditionalInvoiceInformation;
2020-07-15 19:32:59 +02:00
2020-08-05 02:28:37 +02:00
LNDViewAdditionalInvoiceInformation.navigationOptions = () => ({
2020-07-15 19:32:59 +02:00
...BlueNavigationStyle(),
2020-11-28 04:06:37 +01:00
title: loc.lndViewInvoice.additional_info,
2020-07-15 19:32:59 +02:00
});