Skip to content

Instantly share code, notes, and snippets.

@omergulen
Last active July 13, 2018 12:57
Show Gist options
  • Select an option

  • Save omergulen/2bd1847d3c7e9c8bf3462faef35cf6f2 to your computer and use it in GitHub Desktop.

Select an option

Save omergulen/2bd1847d3c7e9c8bf3462faef35cf6f2 to your computer and use it in GitHub Desktop.
Screenshot share code
import React, { Component } from 'react';
import { View, Text, StyleSheet, TouchableHighlight } from 'react-native';
import ViewShot from "react-native-view-shot";
import Share from 'react-native-share';
export default class Yonler extends Component {
constructor(props){
super(props);
...
}
onShare(img){
const shareOptions = {
title: 'Share file',
url: img,
};
return Share.open(shareOptions);
}
render(){
return (
<View style={styles.scores}>
...
<TouchableHighlight style={styles.touchable} onPress={() => {
this.refs.viewShot.capture().then(uri => {
console.warn("do something with ", uri);
this.onShare(uri);
});
}} underlayColor="#f0932b">
<ViewShot ref="viewShot" options={{ format: "jpg", quality: 0.9 }}>
<Text style={styles.buttonText}>PAYLAS</Text>
</ViewShot>
</TouchableHighlight>
</View>
);
}
}
const styles = StyleSheet.create({
touchable:{
height: '25%',
width: '28%',
backgroundColor: '#fed330',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 12,
marginBottom: 20,
marginLeft: 5,
},
scores:{
flexDirection: 'row',
width: '100%',
justifyContent: 'center',
alignItems: 'center',
},
buttonText: {
fontSize: 20,
fontFamily: 'MMA champ',
color: 'black'
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment