-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
CommunicationsLink.js
56 lines (48 loc) · 1.77 KB
/
CommunicationsLink.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import * as Expensicons from './Icon/Expensicons';
import Clipboard from '../libs/Clipboard';
import ContextMenuItem from './ContextMenuItem';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
const propTypes = {
/** Children to wrap in CommunicationsLink. */
children: PropTypes.node.isRequired,
/** Styles to be assigned to Container */
// eslint-disable-next-line react/forbid-prop-types
containerStyles: PropTypes.arrayOf(PropTypes.object),
/** Value to be copied or passed via tap. */
value: PropTypes.string.isRequired,
...withLocalizePropTypes,
};
const defaultProps = {
containerStyles: [],
};
const CommunicationsLink = props => (
<View style={[styles.flexRow, styles.pRelative, ...props.containerStyles]}>
<View style={[
styles.flexRow,
styles.alignItemsCenter,
styles.w100,
styles.communicationsLinkHeight,
]}
>
<View style={styles.flexShrink1}>
{props.children}
</View>
<ContextMenuItem
icon={Expensicons.Clipboard}
text={props.translate('reportActionContextMenu.copyToClipboard')}
successIcon={Expensicons.Checkmark}
successText={props.translate('reportActionContextMenu.copied')}
isMini
onPress={() => Clipboard.setString(props.value)}
/>
</View>
</View>
);
CommunicationsLink.propTypes = propTypes;
CommunicationsLink.defaultProps = defaultProps;
CommunicationsLink.displayName = 'CommunicationsLink';
export default withLocalize(CommunicationsLink);