From 52c8c54b7dd7f0aa3c69dfc7dcd5b42b447063b4 Mon Sep 17 00:00:00 2001 From: chirag-singhal Date: Fri, 4 Sep 2020 09:38:38 +0530 Subject: [PATCH] use cases for share api --- .../js/examples/Share/ShareExample.js | 169 ++++++++---------- 1 file changed, 75 insertions(+), 94 deletions(-) diff --git a/packages/rn-tester/js/examples/Share/ShareExample.js b/packages/rn-tester/js/examples/Share/ShareExample.js index ed3268af252fef..3ec9a7d6f5c89f 100644 --- a/packages/rn-tester/js/examples/Share/ShareExample.js +++ b/packages/rn-tester/js/examples/Share/ShareExample.js @@ -12,115 +12,96 @@ const React = require('react'); -const { - StyleSheet, - View, - Text, - TouchableHighlight, - Share, -} = require('react-native'); +const {StyleSheet, View, Text, Button, Share} = require('react-native'); -type Props = $ReadOnly<{||}>; -type State = {|result: string|}; +const shareMessage = () => { + Share.share({ + message: ('Our top priority for React Native is to match the expectations people have for each platform. This is why React Native renders to platform primitives. We value native look-and-feel over cross-platform consistency.' + + 'For example, the TextInput in React Native renders to a UITextField on iOS. This ensures that integration with password managers and keyboard controls work out of the box. By using platform primitives, React Native apps are also able to stay up-to-date with design and behavior changes from new releases of Android and iOS.': string), + }); +}; -class ShareMessageExample extends React.Component { - _shareMessage: Function; - _shareText: Function; - _showResult: Function; - - constructor(props) { - super(props); - - this._shareMessage = this._shareMessage.bind(this); - this._shareText = this._shareText.bind(this); - this._showResult = this._showResult.bind(this); - - this.state = { - result: '', - }; - } - - render() { - return ( - - - - Click to share message - - - - - Click to share message, URL and title - - - {this.state.result} - - ); - } - - _shareMessage() { - Share.share({ - message: - 'React Native | A framework for building native apps using React', - }) - .then(this._showResult) - .catch(error => this.setState({result: 'error: ' + error.message})); - } +const shareText = () => { + Share.share( + { + title: 'Massive Scale', + message: ('Hundreds of screens in the Facebook app are implemented with React Native. The Facebook app is used by billions of people on a huge range of devices. This is why we invest in the most challenging problems at scale.' + + 'Deploying React Native in our apps lets us identify problems that we wouldn’t see at a smaller scale. For example, Facebook focuses on improving performance across a broad spectrum of devices from the newest iPhone to many older generations of Android devices. This focus informs our architecture projects such as Hermes, Fabric, and TurboModules.': string), + url: 'https://reactnative.dev/blog/2020/07/17/react-native-principles', + }, + { + subject: 'MUST READ: Massive Scale', + dialogTitle: 'Share React Native Blog', + excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'], + tintColor: 'blue', + }, + ); +}; - _shareText() { - Share.share( - { - message: 'A framework for building native apps using React', - url: 'https://reactnative.dev/', - title: 'React Native', - }, - { - subject: 'A subject to go in the email heading', - dialogTitle: 'Share React Native website', - excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'], - tintColor: 'green', - }, - ) - .then(this._showResult) - .catch(error => this.setState({result: 'error: ' + error.message})); - } +const ShareMessageWithoutTitle = () => { + return ( + + Native Experience + + Our top priority for React Native is to match the expectations people + have for each platform. This is why React Native renders to platform + primitives. We value native look-and-feel over cross-platform + consistency. For example, the TextInput in React Native renders to a + UITextField on iOS. This ensures that integration with password managers + and keyboard controls work out of the box. By using platform primitives, + React Native apps are also able to stay up-to-date with design and + behavior changes from new releases of Android and iOS. + +