'use strict';
var React = require('react-native');
var Modal = require('react-native-modal');
var { AppRegistry, StyleSheet, View, Text } = React;
class App extends React.Component {
constructor() {
this.state = {
isModalOpen: false
};
}
openModal() {
this.setState({isModalOpen: true});
}
closeModal() {
this.setState({isModalOpen: false});
}
render() {
return (
<View style={styles.page}>
<Text onPress={() => this.openModal()}>
Open Modal.
</Text>
<Modal isVisible={this.state.isModalOpen} onClose={() => this.closeModal()}>
<Text>Hello world!</Text>
</Modal>
</View>
);
}
}
var styles = StyleSheet.create({
page: {
flex: 1,
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
top: 0
}
});
AppRegistry.registerComponent('App', () => App);
var App = React.createClass({
mixins: [Modal.Mixin],
render() {
return (
<View style={styles.page}>
<Text onPress={() => this.openModal()}>
Open Modal.
</Text>
<Modal backdropType="blur" isVisible={this.state.isModalOpen} onClose={() => this.closeModal()}>
<Text>Hello world!</Text>
</Modal>
</View>
);
}
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步