Feature: Allow XPUB to be copied to clipboard

This commit is contained in:
Pavel Ševčík 2018-12-27 19:29:02 +01:00
parent 46edce17b9
commit 6e4d863eb3
7 changed files with 20 additions and 2 deletions

View File

@ -67,6 +67,7 @@ module.exports = {
},
xpub: {
title: 'wallet XPUB',
copiedToClipboard: 'Copied to clipboard.',
},
import: {
title: 'import',

View File

@ -67,6 +67,7 @@ module.exports = {
},
xpub: {
title: 'wallet XPUB',
copiedToClipboard: 'Copiado a portapapeles.',
},
import: {
title: 'importar',

View File

@ -68,6 +68,7 @@ module.exports = {
},
xpub: {
title: 'wallet XPUB',
copiedToClipboard: 'copiado para clip board',
},
import: {
title: 'importar',

View File

@ -67,6 +67,7 @@ module.exports = {
},
xpub: {
title: 'wallet XPUB',
copiedToClipboard: 'copiado para clip board',
},
import: {
title: 'importar',

View File

@ -67,6 +67,7 @@ module.exports = {
},
xpub: {
title: 'wallet XPUB',
copiedToClipboard: 'скопировано',
},
import: {
title: 'import',

View File

@ -67,6 +67,7 @@ module.exports = {
},
xpub: {
title: 'wallet XPUB',
copiedToClipboard: 'Зкопіювано',
},
import: {
title: 'імпорт',

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Dimensions, Platform, ActivityIndicator, View } from 'react-native';
import { Dimensions, Platform, ActivityIndicator, View, Clipboard, Animated, TouchableOpacity } from 'react-native';
import { QRCode as QRSlow } from 'react-native-custom-qr-codes';
import { BlueSpacing40, SafeBlueArea, BlueCard, BlueText, BlueHeaderDefaultSub } from '../../BlueComponents';
import PropTypes from 'prop-types';
@ -40,6 +40,7 @@ export default class WalletXpub extends Component {
isLoading: true,
wallet,
xpub: wallet.getXpub(),
xpubText: wallet.getXpub(),
};
}
@ -61,6 +62,13 @@ export default class WalletXpub extends Component {
return 312;
};
copyToClipboard = () => {
this.setState({ xpubText: loc.wallets.xpub.copiedToClipboard }, () => {
Clipboard.setString(this.state.xpub);
setTimeout(() => this.setState({ xpubText: this.state.xpub }), 1000);
});
};
render() {
if (this.state.isLoading) {
return (
@ -124,7 +132,11 @@ export default class WalletXpub extends Component {
}
})()}
<BlueText style={{ marginVertical: 8 }}>{this.state.xpub}</BlueText>
<TouchableOpacity onPress={this.copyToClipboard}>
<Animated.Text style={{ marginVertical: 8, textAlign: 'center' }} numberOfLines={0}>
{this.state.xpubText}
</Animated.Text>
</TouchableOpacity>
</BlueCard>
</SafeBlueArea>
);