-
Notifications
You must be signed in to change notification settings - Fork 6
/
PreviewView.ios.js
40 lines (32 loc) · 929 Bytes
/
PreviewView.ios.js
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
'use strict';
var React = require('react-native');
var {
View,
PropTypes,
StyleSheet,
NativeModules,
requireNativeComponent,
} = React;
var { RNPreviewViewManager } = NativeModules;
var RN_PREVIEW_VIEW_REF = 'native-preview-view-ref';
var PreviewView = React.createClass({
propTypes: {
onPop: PropTypes.func,
},
activate({sourceView}) {
RNPreviewViewManager.setSourceView(sourceView);
RNPreviewViewManager.activate(this.getRootNodeHandle());
},
getRootNodeHandle() {
return React.findNodeHandle(this.refs[RN_PREVIEW_VIEW_REF]);
},
render() {
return (
<RNPreviewView ref={RN_PREVIEW_VIEW_REF} onPop={this.props.onPop} style={{position: 'absolute'}}>
{React.Children.map(this.props.children, React.addons.cloneWithProps)}
</RNPreviewView>
);
},
});
var RNPreviewView = requireNativeComponent('RNPreviewView', PreviewView);
module.exports = PreviewView;