Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
parasharrajat committed Jul 9, 2021
1 parent 42e8a12 commit 7a34f08
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimen
import CONST from '../CONST';

const propTypes = {
/** Children to wrap in TappableCopy. */
/** Children to wrap in CommunicationsLink. */
children: PropTypes.node.isRequired,

/** Styles to be assigned to Container */
Expand All @@ -32,7 +32,7 @@ const defaultProps = {
type: undefined,
};

const TappableCopy = props => (
const CommunicationsLink = props => (
<View style={[styles.flexRow, styles.pRelative, ...props.style]}>
{props.type && props.isSmallScreenWidth
? (
Expand All @@ -53,13 +53,13 @@ const TappableCopy = props => (
styles.pAbsolute,
styles.alignItemsCenter,
styles.justifyContentCenter,
{right: -36, top: 0, bottom: 0}]}
styles.communicationsLinkIcon]}
>
<ContextMenuItem
icon={ClipboardIcon}
text={props.translate('reportActionContextMenu.copyToClipboard')}
text={props.translate('contextMenuItem.copyToClipboard')}
successIcon={Checkmark}
successText={props.translate('reportActionContextMenu.copied')}
successText={props.translate('contextMenuItem.copied')}
isMini
autoReset
onPress={() => Clipboard.setString(props.value)}
Expand All @@ -69,11 +69,11 @@ const TappableCopy = props => (
</View>
);

TappableCopy.propTypes = propTypes;
TappableCopy.defaultProps = defaultProps;
TappableCopy.displayName = 'TappableCopy';
CommunicationsLink.propTypes = propTypes;
CommunicationsLink.defaultProps = defaultProps;
CommunicationsLink.displayName = 'CommunicationsLink';

export default compose(
withWindowDimensions,
withLocalize,
)(TappableCopy);
)(CommunicationsLink);
4 changes: 3 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ export default {
youAppearToBeOffline: 'You appear to be offline.',
fileUploadFailed: 'Upload Failed. File is not supported.',
},
reportActionContextMenu: {
contextMenuItem: {
copyToClipboard: 'Copy to Clipboard',
copied: 'Copied!',
},
reportActionContextMenu: {
copyLink: 'Copy Link',
markAsUnread: 'Mark as Unread',
editComment: 'Edit Comment',
Expand Down
10 changes: 5 additions & 5 deletions src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ScreenWrapper from '../components/ScreenWrapper';
import personalDetailsPropType from './personalDetailsPropType';
import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
import compose from '../libs/compose';
import TappableCopy from '../components/TappableCopy';
import CommunicationsLink from '../components/CommunicationsLink';
import CONST from '../CONST';

const matchType = PropTypes.shape({
Expand Down Expand Up @@ -92,7 +92,7 @@ const DetailsPage = ({
imageStyles={[styles.avatarLarge]}
source={details.avatar}
/>
<TappableCopy
<CommunicationsLink
style={[styles.mt1, styles.mb6]}
type={details.displayName && isSMSLogin ? CONST.LOGIN_TYPE.PHONE : undefined}
value={getPhoneNumber(details)}
Expand All @@ -102,15 +102,15 @@ const DetailsPage = ({
? toLocalPhone(details.displayName)
: (details.displayName || null)}
</Text>
</TappableCopy>
</CommunicationsLink>
{details.login ? (
<View style={[styles.mb6, styles.detailsPageSectionContainer]}>
<Text style={[styles.formLabel, styles.mb2]} numberOfLines={1}>
{translate(isSMSLogin
? 'common.phoneNumber'
: 'common.email')}
</Text>
<TappableCopy
<CommunicationsLink
type={isSMSLogin ? CONST.LOGIN_TYPE.PHONE : CONST.LOGIN_TYPE.EMAIL}
value={isSMSLogin ? getPhoneNumber(details) : details.login}
>
Expand All @@ -119,7 +119,7 @@ const DetailsPage = ({
? toLocalPhone(getPhoneNumber(details))
: details.login}
</Text>
</TappableCopy>
</CommunicationsLink>
</View>
) : null}
{details.pronouns ? (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class ReportActionContextMenu extends React.Component {
this.contextActions = [
// Copy to clipboard
{
text: this.props.translate('reportActionContextMenu.copyToClipboard'),
text: this.props.translate('contextMenuItem.copyToClipboard'),
icon: ClipboardIcon,
successText: this.props.translate('reportActionContextMenu.copied'),
successText: this.props.translate('contextMenuItem.copied'),
successIcon: Checkmark,
shouldShow: true,

Expand Down
6 changes: 6 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,12 @@ const styles = {
lineHeight: 16,
...whiteSpace.noWrap,
},

communicationsLinkIcon: {
right: -36,
top: 0,
bottom: 0,
},
};

const baseCodeTagStyles = {
Expand Down

0 comments on commit 7a34f08

Please sign in to comment.