mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
86 lines
2.9 KiB
JavaScript
86 lines
2.9 KiB
JavaScript
import React, { useCallback, useContext, useEffect } from 'react';
|
|
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
|
|
import { View, useWindowDimensions, StyleSheet, BackHandler, ScrollView } from 'react-native';
|
|
import QRCode from 'react-native-qrcode-svg';
|
|
import { BlueButton, BlueCopyTextToClipboard, BlueSpacing20, BlueTextCentered, SafeBlueArea } from '../../BlueComponents';
|
|
import navigationStyle from '../../components/navigationStyle';
|
|
import Privacy from '../../blue_modules/Privacy';
|
|
import loc from '../../loc';
|
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
|
|
|
const PleaseBackupLdk = () => {
|
|
const { wallets } = useContext(BlueStorageContext);
|
|
const { walletID } = useRoute().params;
|
|
/** @type {LightningLdkWallet} */
|
|
const wallet = wallets.find(w => w.getID() === walletID);
|
|
const navigation = useNavigation();
|
|
const { colors } = useTheme();
|
|
const { height, width } = useWindowDimensions();
|
|
const handleBackButton = useCallback(() => {
|
|
navigation.dangerouslyGetParent().pop();
|
|
return true;
|
|
}, [navigation]);
|
|
|
|
const styles = StyleSheet.create({
|
|
root: {
|
|
flex: 1,
|
|
backgroundColor: colors.elevated,
|
|
},
|
|
scrollViewContent: {
|
|
flexGrow: 1,
|
|
backgroundColor: colors.elevated,
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
padding: 20,
|
|
},
|
|
qrCodeContainer: { borderWidth: 6, borderRadius: 8, borderColor: '#FFFFFF' },
|
|
});
|
|
|
|
useEffect(() => {
|
|
Privacy.enableBlur();
|
|
BackHandler.addEventListener('hardwareBackPress', handleBackButton);
|
|
return () => {
|
|
Privacy.disableBlur();
|
|
BackHandler.removeEventListener('hardwareBackPress', handleBackButton);
|
|
};
|
|
}, [handleBackButton]);
|
|
|
|
const pop = () => navigation.dangerouslyGetParent().pop();
|
|
return (
|
|
<SafeBlueArea style={styles.root}>
|
|
<ScrollView centerContent contentContainerStyle={styles.scrollViewContent}>
|
|
<View>
|
|
<BlueTextCentered>Please save this wallet backup. It allows you to restore all your channels on other device.</BlueTextCentered>
|
|
<BlueSpacing20 />
|
|
</View>
|
|
<BlueSpacing20 />
|
|
<View style={styles.qrCodeContainer}>
|
|
<QRCode
|
|
value={wallet.secret}
|
|
logo={require('../../img/qr-code.png')}
|
|
logoSize={90}
|
|
size={height > width ? width - 40 : width / 2}
|
|
color="#000000"
|
|
logoBackgroundColor={colors.brandingColor}
|
|
backgroundColor="#FFFFFF"
|
|
ecl="H"
|
|
/>
|
|
</View>
|
|
<BlueCopyTextToClipboard text={wallet.getSecret()} />
|
|
<BlueSpacing20 />
|
|
<BlueButton onPress={pop} title={loc.pleasebackup.ok_lnd} />
|
|
</ScrollView>
|
|
</SafeBlueArea>
|
|
);
|
|
};
|
|
|
|
PleaseBackupLdk.navigationOptions = navigationStyle({
|
|
title: loc.pleasebackup.title,
|
|
gestureEnabled: false,
|
|
swipeEnabled: false,
|
|
headerHideBackButton: true,
|
|
});
|
|
|
|
export default PleaseBackupLdk;
|