2020-11-28 04:06:37 +01:00
|
|
|
import React, { useContext, useEffect, useState } from 'react';
|
2020-05-24 11:17:26 +02:00
|
|
|
import { View, Share, StyleSheet } from 'react-native';
|
2023-10-24 03:28:44 +02:00
|
|
|
import { useNavigation, useRoute } from '@react-navigation/native';
|
2023-12-27 07:52:11 +01:00
|
|
|
import { BlueCopyTextToClipboard, BlueLoading, BlueSpacing20, BlueText } from '../../BlueComponents';
|
2020-12-25 17:09:53 +01:00
|
|
|
import navigationStyle from '../../components/navigationStyle';
|
|
|
|
import loc from '../../loc';
|
2020-11-28 04:06:37 +01:00
|
|
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
2021-08-27 03:31:36 +02:00
|
|
|
import QRCodeComponent from '../../components/QRCodeComponent';
|
2024-02-07 20:24:24 +01:00
|
|
|
import presentAlert from '../../components/Alert';
|
2023-10-24 03:28:44 +02:00
|
|
|
import { useTheme } from '../../components/themes';
|
2023-11-15 13:54:04 +01:00
|
|
|
import Button from '../../components/Button';
|
2023-12-27 07:52:11 +01:00
|
|
|
import SafeArea from '../../components/SafeArea';
|
2020-11-28 04:06:37 +01:00
|
|
|
|
|
|
|
const LNDViewAdditionalInvoiceInformation = () => {
|
|
|
|
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);
|
2024-02-07 20:24:24 +01:00
|
|
|
presentAlert({ message: loc.errors.network });
|
2020-11-28 04:06:37 +01:00
|
|
|
goBack();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [wallet]);
|
|
|
|
|
|
|
|
if (walletInfo === undefined) {
|
|
|
|
return (
|
2023-12-27 07:52:11 +01:00
|
|
|
<SafeArea style={[styles.loading, stylesHook.loading]}>
|
2020-11-28 04:06:37 +01:00
|
|
|
<BlueLoading />
|
2023-12-27 07:52:11 +01:00
|
|
|
</SafeArea>
|
2020-11-28 04:06:37 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2023-12-27 07:52:11 +01:00
|
|
|
<SafeArea style={stylesHook.root}>
|
2020-11-28 04:06:37 +01:00
|
|
|
<View style={styles.wrapper}>
|
|
|
|
<View style={styles.qrcode}>
|
2021-08-27 03:31:36 +02:00
|
|
|
<QRCodeComponent value={walletInfo.uris[0]} size={300} />
|
2020-11-28 04:06:37 +01:00
|
|
|
</View>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<BlueText>{loc.lndViewInvoice.open_direct_channel}</BlueText>
|
|
|
|
<BlueCopyTextToClipboard text={walletInfo.uris[0]} />
|
|
|
|
<View style={styles.share}>
|
2023-11-15 13:54:04 +01:00
|
|
|
<Button
|
2020-11-28 04:06:37 +01:00
|
|
|
icon={{
|
|
|
|
name: 'share-alternative',
|
|
|
|
type: 'entypo',
|
|
|
|
color: colors.buttonTextColor,
|
|
|
|
}}
|
|
|
|
onPress={async () => {
|
|
|
|
Share.share({
|
|
|
|
message: walletInfo.uris[0],
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
title={loc.receive.details_share}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</View>
|
2023-12-27 07:52:11 +01:00
|
|
|
</SafeArea>
|
2020-11-28 04:06:37 +01:00
|
|
|
);
|
|
|
|
};
|
2018-12-29 02:15:59 +01:00
|
|
|
|
2020-05-24 11:17:26 +02:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
loading: {
|
2020-08-05 02:28:37 +02:00
|
|
|
justifyContent: 'space-between',
|
2020-05-24 11:17:26 +02:00
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
wrapper: {
|
|
|
|
flex: 1,
|
2020-08-05 02:28:37 +02:00
|
|
|
justifyContent: 'center',
|
2020-05-24 11:17:26 +02:00
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
qrcode: {
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
share: {
|
|
|
|
marginBottom: 25,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-11-28 04:06:37 +01:00
|
|
|
export default LNDViewAdditionalInvoiceInformation;
|
2020-07-15 19:32:59 +02:00
|
|
|
|
2021-02-15 09:03:54 +01:00
|
|
|
LNDViewAdditionalInvoiceInformation.navigationOptions = navigationStyle({}, opts => ({
|
|
|
|
...opts,
|
2020-11-28 04:06:37 +01:00
|
|
|
title: loc.lndViewInvoice.additional_info,
|
2021-02-15 09:03:54 +01:00
|
|
|
}));
|