index.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React, { FC, ReactNode } from 'react';
  2. import { Dimensions, DimensionValue, View } from 'react-native';
  3. import ReactModal from 'react-native-modal';
  4. import { ModalHeader } from './ModalHeader/modal-header';
  5. import { styles } from './style';
  6. import { statusBarHeight } from 'src/constants/constants';
  7. type Props = {
  8. children: ReactNode;
  9. visible: boolean;
  10. onRequestClose?: () => void;
  11. visibleInPercent?: DimensionValue;
  12. headerTitle: string;
  13. };
  14. export const Modal: FC<Props> = ({
  15. children,
  16. onRequestClose,
  17. visible,
  18. visibleInPercent,
  19. headerTitle
  20. }) => {
  21. const screenHeight = Dimensions.get('screen').height;
  22. const adjustedHeight = screenHeight - statusBarHeight;
  23. return (
  24. <ReactModal
  25. isVisible={visible}
  26. onBackdropPress={onRequestClose}
  27. onBackButtonPress={onRequestClose}
  28. style={styles.modal}
  29. statusBarTranslucent={true}
  30. presentationStyle="overFullScreen"
  31. >
  32. <View style={[styles.wrapper, { height: visibleInPercent ?? adjustedHeight }]}>
  33. <ModalHeader onRequestClose={onRequestClose} textHeader={headerTitle} />
  34. <Drawer />
  35. {children}
  36. </View>
  37. </ReactModal>
  38. );
  39. };
  40. const Drawer = () => {
  41. return <View style={styles.drawer} />;
  42. };