Skip to content

Commit 2ce3ba2

Browse files
committed
Create modal custom component
1 parent 2e5385b commit 2ce3ba2

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React from 'react';
2+
import {View, StyleSheet, StyleProp, ViewStyle, Text} from 'react-native';
3+
import {theme} from '../../theme/theme';
4+
5+
import Modal, {ModalProps} from 'react-native-modal';
6+
import ButtonComponent from '../Button/ButtonComponent';
7+
8+
interface Props {
9+
hideModal: () => void;
10+
style?: StyleProp<ViewStyle>;
11+
}
12+
13+
const ModalComponent = ({
14+
hideModal,
15+
style,
16+
children,
17+
...props
18+
}: Props & Partial<ModalProps>) => {
19+
return (
20+
<Modal {...props}>
21+
<View style={[styles.modal, style]}>
22+
<Text style={styles.text}>Place for your content</Text>
23+
<ButtonComponent
24+
title="Close"
25+
style={styles.closeButton}
26+
onClick={hideModal}
27+
/>
28+
{children}
29+
</View>
30+
</Modal>
31+
);
32+
};
33+
34+
const styles = StyleSheet.create({
35+
closeButton: {
36+
position: 'absolute',
37+
top: 20,
38+
right: 20,
39+
width: theme.buttons.smallWidth,
40+
height: theme.buttons.smallHeight,
41+
},
42+
modal: {
43+
flex: 1,
44+
justifyContent: 'center',
45+
alignItems: 'center',
46+
backgroundColor: theme.colors.white,
47+
borderRadius: 30,
48+
},
49+
text: {
50+
fontSize: theme.fontSizes.standard,
51+
},
52+
});
53+
54+
export default ModalComponent;

0 commit comments

Comments
 (0)