2024-03-27 05:37:43 +01:00
|
|
|
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';
|
2024-03-27 05:37:43 +01:00
|
|
|
|
|
|
|
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);
|
2024-03-27 05:37:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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' },
|
2024-03-27 05:37:43 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
export default CopyToClipboardButton;
|