BlueWallet/components/CopyToClipboardButton.tsx

31 lines
981 B
TypeScript
Raw Normal View History

import Clipboard from '@react-native-clipboard/clipboard';
import React from 'react';
2024-05-20 11:54:13 +02:00
import { StyleSheet, Text, TouchableOpacity } from 'react-native';
2024-04-12 00:40:52 +02:00
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
2024-05-20 11:54:13 +02:00
import loc from '../loc';
type CopyToClipboardButtonProps = {
stringToCopy: string;
displayText?: string;
};
export const CopyToClipboardButton: React.FC<CopyToClipboardButtonProps> = ({ stringToCopy, displayText }) => {
const onPress = () => {
Clipboard.setString(stringToCopy);
2024-04-12 00:40:52 +02:00
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({
2024-04-12 00:40:52 +02:00
text: { fontSize: 16, fontWeight: '400', color: '#68bbe1' },
});
export default CopyToClipboardButton;