forked from brentvatne/PeekPopAttempt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Peekable.ios.js
49 lines (41 loc) · 994 Bytes
/
Peekable.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
41
42
43
44
45
46
47
48
49
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
PropTypes,
TouchableWithoutFeedback,
NativeModules,
} = React;
var Peekable = {};
var PREVIEW_REF = 'peekable-preview';
Peekable.Preview = require('./PreviewView');
Peekable.View = React.createClass({
propTypes: {
renderPreview: PropTypes.func,
onPop: PropTypes.func,
...View.propTypes,
},
render() {
let preview = (
<Peekable.Preview ref={PREVIEW_REF} onPop={this.props.onPop}>
{this.props.renderPreview()}
</Peekable.Preview>
);
return (
<TouchableWithoutFeedback onPressIn={this._handlePressIn}>
<View {...this.props} ref={(view) => { this._root = view; }}>
{this.props.children}
{preview}
</View>
</TouchableWithoutFeedback>
)
},
_handlePressIn() {
this.refs[PREVIEW_REF].activate({
sourceView: React.findNodeHandle(this._root)
});
},
});
module.exports = Peekable;