mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
31 lines
981 B
TypeScript
31 lines
981 B
TypeScript
import Clipboard from '@react-native-clipboard/clipboard';
|
|
import React from 'react';
|
|
import { StyleSheet, Text, TouchableOpacity } from 'react-native';
|
|
|
|
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
|
|
import loc from '../loc';
|
|
|
|
type CopyToClipboardButtonProps = {
|
|
stringToCopy: string;
|
|
displayText?: string;
|
|
};
|
|
|
|
export const CopyToClipboardButton: React.FC<CopyToClipboardButtonProps> = ({ stringToCopy, displayText }) => {
|
|
const onPress = () => {
|
|
Clipboard.setString(stringToCopy);
|
|
triggerHapticFeedback(HapticFeedbackTypes.Selection);
|
|
};
|
|
|
|
return (
|
|
<TouchableOpacity accessibilityRole="button" onPress={onPress}>
|
|
<Text style={styles.text}>{displayText && displayText.length > 0 ? displayText : loc.transactions.details_copy}</Text>
|
|
</TouchableOpacity>
|
|
);
|
|
};
|
|
|
|
const styles = StyleSheet.create({
|
|
text: { fontSize: 16, fontWeight: '400', color: '#68bbe1' },
|
|
});
|
|
|
|
export default CopyToClipboardButton;
|