-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.js
More file actions
72 lines (63 loc) · 1.99 KB
/
index.js
File metadata and controls
72 lines (63 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var React = require('react');
var {Component} = React;
var ReactNative = require('react-native');
var {
requireNativeComponent,
NativeModules,
StyleSheet,
TouchableWithoutFeedback,
} = ReactNative;
const blue = '#0084ff';
class FBMessengerButton extends Component {
render() {
return (
<TouchableWithoutFeedback style={[styles.sendToMessengerWrapper, this.props.style]} onPress={this.props.onPress.bind(this)}>
<RCTFBMessengerButton style={[styles.sendToMessengerWrapper, this.props.style]}/>
</TouchableWithoutFeedback>
);
}
}
FBMessengerButton.propTypes = {
/**
* When this property is set to `true` and a valid camera is associated
* with the map, the camera’s pitch angle is used to tilt the plane
* of the map. When this property is set to `false`, the camera’s pitch
* angle is ignored and the map is always displayed as if the user
* is looking straight down onto it.
*/
//pitchEnabled: React.PropTypes.bool,
};
var styles = StyleSheet.create({
sendToMessengerWrapper: {
width: 300,
height: 50,
backgroundColor: blue,
flex: 1,
alignSelf: 'center',
}
});
var RCTFBMessengerButton = requireNativeComponent('RCTFBMessengerButton', FBMessengerButton);
const ShareType = {
image: 'image',
gif: 'gif',
video: 'video',
audio: 'audio',
};
function send(type, filePath, metadata){
if(type in ShareType) {
if(typeof metadata !== 'string'){
metadata = JSON.stringify(metadata);
}
NativeModules.RNFBMessenger.send(type, filePath, metadata);
} else {
throw new Error(`
"${type}" is not a valid type for this method.
Valid values are: ShareType.image, ShareType.gif, ShareType.video, ShareType.audio`);
}
}
module.exports = {
Button: FBMessengerButton,
backToMessenger: NativeModules.RNFBMessenger.backToMessenger,
send: send,
ShareType: ShareType,
};