mirror of
https://github.com/morten-olsen/react-native-debug-console.git
synced 2026-02-08 00:36:26 +01:00
init
This commit is contained in:
64
lib/src/components/DevTool/Modal.js
Normal file
64
lib/src/components/DevTool/Modal.js
Normal file
@@ -0,0 +1,64 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Modal,
|
||||
} from 'react-native';
|
||||
import events from '../../events';
|
||||
import DevTool from './index';
|
||||
|
||||
|
||||
class Events extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
visible: false,
|
||||
};
|
||||
this.listen = this.listen.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
events.listen(this.listen);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
events.unlisten(this.listen);
|
||||
}
|
||||
|
||||
listen(type, data) {
|
||||
if (type === 'SHOW_DEVTOOLS') {
|
||||
return this.setState({
|
||||
visible: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (type === 'HIDE_DEVTOOLS') {
|
||||
return this.setState({
|
||||
visible: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal
|
||||
animationType="slide"
|
||||
transparent={false}
|
||||
visible={this.state.visible}
|
||||
onRequestClose={() => {
|
||||
}}
|
||||
>
|
||||
<Fragment>
|
||||
<DevTool />
|
||||
<Button
|
||||
title="close"
|
||||
onPress={() => {
|
||||
events.publish('HIDE_DEVTOOLS');
|
||||
}}
|
||||
/>
|
||||
</Fragment>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Events;
|
||||
Reference in New Issue
Block a user