MyModal.js 934 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import React from 'react';
  2. import { StyleSheet, Modal, View, Text } from 'react-native';
  3. import Dialog from './Dialog';
  4. const MyModal = ({
  5. visible=false,
  6. style=styles.content,
  7. layerStyle=styles.dialog,
  8. animationType="fade",
  9. onLayerPress,
  10. children
  11. }) => (
  12. <Modal
  13. visible={visible}
  14. transparent={true}
  15. animationType={animationType}
  16. statusBarTranslucent={true}>
  17. <View style={layerStyle}>
  18. <Text
  19. style={StyleSheet.absoluteFillObject}
  20. onPress={onLayerPress}>
  21. </Text>
  22. <View style={style}>
  23. {children}
  24. </View>
  25. </View>
  26. </Modal>
  27. );
  28. export default MyModal;
  29. const styles = StyleSheet.create({
  30. dialog: {
  31. flex: 1,
  32. alignItems: 'center',
  33. justifyContent: 'center',
  34. backgroundColor: 'rgba(0,0,0,.5)'
  35. },
  36. content: {
  37. width: Dialog.dialogWidth,
  38. borderRadius: isIOS ? 16 : 8,
  39. overflow: 'hidden',
  40. backgroundColor: colorLight
  41. }
  42. })