react-native-share-menu
Advanced tools
Comparing version 3.0.0 to 3.1.0
{ | ||
"name": "react-native-share-menu", | ||
"description": "Adds the app to share menu, so it can be launched from share menu and receive data from other apps", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -7,3 +7,3 @@ # react-native-share-menu | ||
* Install the module | ||
- Install the module | ||
@@ -34,3 +34,3 @@ ```bash | ||
* In `android/settings.gradle` | ||
- In `android/settings.gradle` | ||
@@ -43,3 +43,3 @@ ```gradle | ||
* In `android/app/build.gradle` | ||
- In `android/app/build.gradle` | ||
@@ -54,3 +54,3 @@ ```gradle | ||
* In `android/app/src/main/AndroidManifest.xml` in the `<activity>` tag: | ||
- In `android/app/src/main/AndroidManifest.xml` in the `<activity>` tag: | ||
@@ -71,3 +71,3 @@ ```xml | ||
* Register module (in MainApplication.java) | ||
- Register module (in MainApplication.java) | ||
@@ -178,3 +178,3 @@ ```java | ||
... | ||
- (BOOL)application:(UIApplication *)app | ||
@@ -192,43 +192,42 @@ openURL:(NSURL *)url | ||
```javascript | ||
import React, { | ||
AppRegistry, | ||
Component, | ||
Text, | ||
View | ||
} from 'react-native'; | ||
import ShareMenu from 'react-native-share-menu'; | ||
import React, { useState, useEffect, useCallback } from "react"; | ||
import { AppRegistry, Text, View, Image } from "react-native"; | ||
import ShareMenu from "react-native-share-menu"; | ||
class Test extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
sharedText: null, | ||
sharedImage: null | ||
}; | ||
} | ||
const Test = () => { | ||
const [sharedText, setSharedText] = useState(null); | ||
const [sharedImage, setSharedImage] = useState(null); | ||
componentWillMount() { | ||
var that = this; | ||
ShareMenu.getSharedText((text :string) => { | ||
if (text && text.length) { | ||
if (text.startsWith('content://media/') || text.startsWith('file://')) { | ||
that.setState({ sharedImage: text }); | ||
} else { | ||
that.setState({ sharedText: text }); | ||
} | ||
const handleShare = useCallback((text: string) => { | ||
if (text.length) { | ||
if (text.startsWith("content://") || text.startsWith("file://")) { | ||
setSharedImage(text); | ||
} else { | ||
setSharedText(text); | ||
} | ||
}) | ||
} | ||
} | ||
}, []); | ||
render() { | ||
var text = this.state.sharedText; | ||
return ( | ||
<View> | ||
<Text>Shared text: {text}</Text> | ||
</View> | ||
); | ||
} | ||
} | ||
useEffect(() => { | ||
ShareMenu.getInitialShare(handleShare); | ||
}, []); | ||
AppRegistry.registerComponent('Test', () => Test); | ||
useEffect(() => { | ||
const listener = ShareMenu.addNewShareListener(handleShare); | ||
return () => { | ||
listener.remove(); | ||
}; | ||
}, []); | ||
return ( | ||
<View> | ||
<Text>Shared text: {sharedText}</Text> | ||
<Text>Shared image:</Text> | ||
<Image source={{ uri: sharedImage }} /> | ||
</View> | ||
); | ||
}; | ||
AppRegistry.registerComponent("Test", () => Test); | ||
``` | ||
@@ -249,1 +248,3 @@ | ||
Sponsored and developed by [Meedan](http://meedan.com). | ||
iOS version maintained by [Gustavo Parreira](https://github.com/Gustash). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2771929
159
243