|
| 1 | +import React from 'react'; |
| 2 | +import type {StyleProp, ViewStyle} from 'react-native'; |
| 3 | +import {View} from 'react-native'; |
| 4 | +import useLocalize from '@hooks/useLocalize'; |
| 5 | +import useThemeStyles from '@hooks/useThemeStyles'; |
| 6 | +import Clipboard from '@libs/Clipboard'; |
| 7 | +import type ChildrenProps from '@src/types/utils/ChildrenProps'; |
| 8 | +import ContextMenuItem from './ContextMenuItem'; |
| 9 | +import * as Expensicons from './Icon/Expensicons'; |
| 10 | + |
| 11 | +type CommunicationsLinkProps = ChildrenProps & { |
| 12 | + /** Styles to be assigned to Container */ |
| 13 | + containerStyles?: StyleProp<ViewStyle>; |
| 14 | + |
| 15 | + /** Value to be copied or passed via tap. */ |
| 16 | + value: string; |
| 17 | +}; |
| 18 | + |
| 19 | +function CommunicationsLink({value, containerStyles, children}: CommunicationsLinkProps) { |
| 20 | + const styles = useThemeStyles(); |
| 21 | + const {translate} = useLocalize(); |
| 22 | + |
| 23 | + return ( |
| 24 | + <View style={[styles.flexRow, styles.pRelative, containerStyles]}> |
| 25 | + <View style={[styles.flexRow, styles.alignItemsCenter, styles.w100, styles.communicationsLinkHeight]}> |
| 26 | + <View style={styles.flexShrink1}>{children}</View> |
| 27 | + <ContextMenuItem |
| 28 | + icon={Expensicons.Copy} |
| 29 | + text={translate('reportActionContextMenu.copyToClipboard')} |
| 30 | + successIcon={Expensicons.Checkmark} |
| 31 | + successText={translate('reportActionContextMenu.copied')} |
| 32 | + isMini |
| 33 | + onPress={() => Clipboard.setString(value)} |
| 34 | + /> |
| 35 | + </View> |
| 36 | + </View> |
| 37 | + ); |
| 38 | +} |
| 39 | + |
| 40 | +CommunicationsLink.displayName = 'CommunicationsLink'; |
| 41 | + |
| 42 | +export default CommunicationsLink; |
0 commit comments