-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3870 from parasharrajat/tap-details
Added tapable links to user's login information on DetailsPage
- Loading branch information
Showing
6 changed files
with
145 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from 'react'; | ||
import {View, Pressable, Linking} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import styles from '../styles/styles'; | ||
import compose from '../libs/compose'; | ||
import {Checkmark, Clipboard as ClipboardIcon} from './Icon/Expensicons'; | ||
import Clipboard from '../libs/Clipboard'; | ||
import ContextMenuItem from './ContextMenuItem'; | ||
import withLocalize, {withLocalizePropTypes} from './withLocalize'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; | ||
import CONST from '../CONST'; | ||
|
||
const propTypes = { | ||
/** Children to wrap in CommunicationsLink. */ | ||
children: PropTypes.node.isRequired, | ||
|
||
/** Styles to be assigned to Container */ | ||
containerStyles: PropTypes.arrayOf(PropTypes.object), | ||
|
||
/** Decides Tap behaviour. */ | ||
type: PropTypes.oneOf([CONST.LOGIN_TYPE.PHONE, CONST.LOGIN_TYPE.EMAIL]).isRequired, | ||
|
||
/** Value to be copied or passed via tap. */ | ||
value: PropTypes.string.isRequired, | ||
|
||
...windowDimensionsPropTypes, | ||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
containerStyles: [], | ||
}; | ||
|
||
const CommunicationsLink = props => ( | ||
<View style={[styles.flexRow, styles.pRelative, ...props.containerStyles]}> | ||
{props.isSmallScreenWidth | ||
? ( | ||
<Pressable | ||
onPress={() => Linking.openURL( | ||
props.type === CONST.LOGIN_TYPE.PHONE | ||
? `tel:${props.value}` | ||
: `mailto:${props.value}`, | ||
)} | ||
> | ||
{props.children} | ||
</Pressable> | ||
) | ||
: props.children} | ||
{!props.isSmallScreenWidth | ||
&& ( | ||
<View style={[ | ||
styles.pAbsolute, | ||
styles.alignItemsCenter, | ||
styles.justifyContentCenter, | ||
styles.communicationsLinkIcon]} | ||
> | ||
<ContextMenuItem | ||
icon={ClipboardIcon} | ||
text={props.translate('contextMenuItem.copyToClipboard')} | ||
successIcon={Checkmark} | ||
successText={props.translate('contextMenuItem.copied')} | ||
isMini | ||
autoReset | ||
onPress={() => Clipboard.setString(props.value)} | ||
/> | ||
</View> | ||
)} | ||
</View> | ||
); | ||
|
||
CommunicationsLink.propTypes = propTypes; | ||
CommunicationsLink.defaultProps = defaultProps; | ||
CommunicationsLink.displayName = 'CommunicationsLink'; | ||
|
||
export default compose( | ||
withWindowDimensions, | ||
withLocalize, | ||
)(CommunicationsLink); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters