'use strict';
var React = require('react-native');
var Overlay = require('./overlay');
var { AppRegistry, StyleSheet, View, Text } = React;
var YApp = React.createClass({
getInitialState() {
return {
isOverlayOpen: true
}
},
closeOverlay() {
this.setState({isOverlayOpen: false});
},
render() {
return (
<View style={styles.page}>
<Overlay onPressBackdrop={this.closeOverlay} isVisible={this.state.isOverlayOpen} Opacity={0.5}/>
</View>
);
}
});
var styles = StyleSheet.create({
page: {
flex: 1,
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
top: 0
}
});
AppRegistry.registerComponent('App', () => App);
##API
name | type | default | description |
---|---|---|---|
onPressBackdrop | Function | noop | 点击Overlay触发的回调函数 |
isVisible | Boolean | true | 是否显示Overlay |
Opacity | Int | 0.5 | Overlay透明度 |
MIT Licensed