/**
 * Copyright (c) JOB TODAY S.A. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */
import { useEffect } from 'react';
import { BackHandler, View, StyleSheet, StatusBar } from 'react-native';
const Modal = ({
  visible,
  children,
  presentationStyle,
  onRequestClose
}) => {
  if (!visible) {
    return null;
  }
  useEffect(() => {
    const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
      if (typeof onRequestClose === 'function') {
        onRequestClose();
      }
      return true;
    });
    return () => {
      backHandler.remove();
    };
  }, []);
  const statusBarHidden = presentationStyle === 'overFullScreen';
  const statusBarStateStyle = presentationStyle === 'overFullScreen' ? styles.overFullscreen : styles.defaultStyle;
  return /*#__PURE__*/React.createElement(React.Fragment, null, statusBarHidden && /*#__PURE__*/React.createElement(StatusBar, {
    hidden: true
  }), /*#__PURE__*/React.createElement(View, {
    style: [styles.root, statusBarStateStyle]
  }, children));
};
const styles = StyleSheet.create({
  root: {
    ...StyleSheet.absoluteFillObject,
    zIndex: 1000,
    backgroundColor: 'transparent'
  },
  overFullscreen: {
    top: 0
  },
  defaultStyle: {
    top: StatusBar.currentHeight
  }
});
export default Modal;
//# sourceMappingURL=Modal.android.js.map