mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-03 20:07:11 +01:00
ADD: Tap and hold to Share QRCode image
This commit is contained in:
parent
a2a53f6269
commit
43f79e8f07
1 changed files with 33 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React, { useCallback, useContext, useState } from 'react';
|
import React, { useCallback, useContext, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
InteractionManager,
|
InteractionManager,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
|
@ -35,6 +35,8 @@ import DeeplinkSchemaMatch from '../../class/deeplink-schema-match';
|
||||||
import loc from '../../loc';
|
import loc from '../../loc';
|
||||||
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
import { BlueStorageContext } from '../../blue_modules/storage-context';
|
||||||
import Notifications from '../../blue_modules/notifications';
|
import Notifications from '../../blue_modules/notifications';
|
||||||
|
import ToolTipMenu from '../../components/TooltipMenu';
|
||||||
|
import { TouchableWithoutFeedback } from 'react-native-gesture-handler';
|
||||||
const currency = require('../../blue_modules/currency');
|
const currency = require('../../blue_modules/currency');
|
||||||
|
|
||||||
const ReceiveDetails = () => {
|
const ReceiveDetails = () => {
|
||||||
|
@ -51,6 +53,8 @@ const ReceiveDetails = () => {
|
||||||
const [showAddress, setShowAddress] = useState(false);
|
const [showAddress, setShowAddress] = useState(false);
|
||||||
const { navigate, goBack } = useNavigation();
|
const { navigate, goBack } = useNavigation();
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
const toolTip = useRef();
|
||||||
|
const qrCode = useRef();
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
modalContent: {
|
modalContent: {
|
||||||
backgroundColor: colors.modal,
|
backgroundColor: colors.modal,
|
||||||
|
@ -130,6 +134,18 @@ const ReceiveDetails = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleShareQRCode = () => {
|
||||||
|
qrCode.current.toDataURL(data => {
|
||||||
|
const shareImageBase64 = {
|
||||||
|
url: `data:image/png;base64,${data}`,
|
||||||
|
};
|
||||||
|
Share.open(shareImageBase64).catch(error => console.log(error));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const showToolTipMenu = () => {
|
||||||
|
toolTip.current.showMenu();
|
||||||
|
};
|
||||||
const renderReceiveDetails = () => {
|
const renderReceiveDetails = () => {
|
||||||
return (
|
return (
|
||||||
<ScrollView style={styles.root} contentContainerStyle={styles.scroll} keyboardShouldPersistTaps="always">
|
<ScrollView style={styles.root} contentContainerStyle={styles.scroll} keyboardShouldPersistTaps="always">
|
||||||
|
@ -144,7 +160,20 @@ const ReceiveDetails = () => {
|
||||||
</BlueText>
|
</BlueText>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<View style={styles.qrCodeContainer} testID="BitcoinAddressQRCodeContainer">
|
<TouchableWithoutFeedback style={styles.qrCodeContainer} testID="BitcoinAddressQRCodeContainer" onLongPress={showToolTipMenu}>
|
||||||
|
<ToolTipMenu
|
||||||
|
ref={toolTip}
|
||||||
|
anchorRef={qrCode}
|
||||||
|
actions={[
|
||||||
|
{
|
||||||
|
id: 'shareQRCode',
|
||||||
|
text: loc.receive.details_share,
|
||||||
|
onPress: handleShareQRCode,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
onPress={handleShareQRCode}
|
||||||
|
/>
|
||||||
|
|
||||||
<QRCode
|
<QRCode
|
||||||
value={bip21encoded}
|
value={bip21encoded}
|
||||||
logo={require('../../img/qr-code.png')}
|
logo={require('../../img/qr-code.png')}
|
||||||
|
@ -154,8 +183,9 @@ const ReceiveDetails = () => {
|
||||||
logoBackgroundColor={colors.brandingColor}
|
logoBackgroundColor={colors.brandingColor}
|
||||||
backgroundColor="#FFFFFF"
|
backgroundColor="#FFFFFF"
|
||||||
ecl="H"
|
ecl="H"
|
||||||
|
getRef={qrCode}
|
||||||
/>
|
/>
|
||||||
</View>
|
</TouchableWithoutFeedback>
|
||||||
<BlueCopyTextToClipboard text={isCustom ? bip21encoded : address} />
|
<BlueCopyTextToClipboard text={isCustom ? bip21encoded : address} />
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.share}>
|
<View style={styles.share}>
|
||||||
|
|
Loading…
Add table
Reference in a new issue