-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGenericModal.js
57 lines (47 loc) · 1.19 KB
/
GenericModal.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
50
51
52
53
54
55
56
57
import React, { Component } from 'react';
import { Dimensions, StyleSheet, View } from 'react-native';
import PropTypes from 'prop-types';
const { width, height } = Dimensions.get('window');
class GenericModal extends Component {
static propTypes = {
containerStyle: PropTypes.object,
};
state = {
isVisible: false,
component: null,
};
dismissModal = () => {
this.setState({
isVisible: false,
});
};
showModal = (component) => {
this.setState({
isVisible: true,
component,
});
};
render() {
const { isVisible, component } = this.state;
const {containerStyle} = this.props;
if (!isVisible) return null;
return (
<View style={[styles.container, containerStyle]}>
{component}
</View>);
}
}
export default GenericModal;
const styles = StyleSheet.create({
container: {
position: 'absolute',
top: 0,
left: 0,
height,
width,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'rgba(255,255,255,0.5)',
zIndex: 100,
},
});