* The ShareButton is a virtual component that wraps a button with a share icon. * It puts the sharing logic in one place. It's used in the navigation bar in the toolkit, * but it can be reused anywhere. * * It should have the style of its underlying button. That's why it's not connected to style
| 16 | * or animation. |
| 17 | */ |
| 18 | class ShareButton extends PureComponent { |
| 19 | constructor(props) { |
| 20 | super(props); |
| 21 | |
| 22 | autoBindReact(this); |
| 23 | } |
| 24 | |
| 25 | onShare() { |
| 26 | const { title, message, url } = this.props; |
| 27 | |
| 28 | return Share.share({ |
| 29 | title, |
| 30 | // URL property isn't supported on Android, so we are |
| 31 | // including it as the message for now. |
| 32 | message: Platform.OS === 'android' ? url : message, |
| 33 | url, |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | render() { |
| 38 | const { animationName, iconProps, url, ...otherProps } = this.props; |
| 39 | |
| 40 | if (!url) { |
| 41 | return null; |
| 42 | } |
| 43 | |
| 44 | return ( |
| 45 | <Button onPress={unavailableInWeb(this.onShare)} {...otherProps}> |
| 46 | <Icon |
| 47 | name={Platform.OS === 'ios' ? 'share' : 'share-android'} |
| 48 | animationName={animationName} |
| 49 | {...iconProps} |
| 50 | /> |
| 51 | </Button> |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | ShareButton.propTypes = { |
| 57 | // Animation name for share icon |
nothing calls this directly
no outgoing calls
no test coverage detected