import React, { useState, useEffect } from 'react';
import { StyleSheet, View } from 'react-native';
import HeaderBackButton from '../../atom/header-back-button/index.native';
import { useTemplateContext } from '../../template/app-review/template-context';
export const HEADER_HEIGHT = 64;
const createStyleSheet = theme => StyleSheet.create({
  container: {
    borderRadius: theme.radius.card,
    overflow: 'hidden',
    backgroundColor: theme.colors.white
  },
  header: {
    backgroundColor: theme.colors.white,
    alignItems: 'flex-end',
    justifyContent: 'center',
    paddingHorizontal: theme.spacing.medium,
    height: HEADER_HEIGHT
  },
  content: {
    paddingHorizontal: theme.spacing.medium,
    paddingBottom: theme.spacing.medium,
    alignItems: 'center'
  },
  contentWithHeader: {
    paddingTop: theme.spacing.medium
  },
  contentWithIcon: {
    paddingTop: theme.spacing.small
  },
  icon: {
    marginTop: -HEADER_HEIGHT * (3 / 4),
    padding: 5,
    backgroundColor: theme.colors.white,
    borderRadius: theme.radius.thumbnail,
    alignSelf: 'center'
  },
  iconContent: {
    backgroundColor: theme.colors.white,
    padding: theme.spacing.small,
    borderRadius: theme.radius.thumbnail,
    justifyContent: 'center',
    alignItems: 'center'
  }
});
const Modal = props => {
  const templateContext = useTemplateContext();
  const [styleSheet, setStylesheet] = useState(null);
  const {
    theme
  } = templateContext;
  const {
    children,
    headerBackgroundColor,
    iconBackgroundColor,
    renderIcon,
    contentStyle,
    onClose,
    testID
  } = props;
  useEffect(() => {
    const _stylesheet = createStyleSheet(theme);
    setStylesheet(_stylesheet);
  }, [theme]);
  if (!styleSheet) {
    return null;
  }
  const contentStyles = [styleSheet.content, contentStyle];
  return /*#__PURE__*/React.createElement(View, {
    style: styleSheet.container,
    testID: testID
  }, /*#__PURE__*/React.createElement(View, {
    style: [styleSheet.header, {
      backgroundColor: headerBackgroundColor
    }]
  }, /*#__PURE__*/React.createElement(HeaderBackButton, {
    color: theme.colors.gray.dark,
    isFloating: false,
    testID: "close-modal",
    onPress: onClose,
    type: "close"
  })), renderIcon ? /*#__PURE__*/React.createElement(View, {
    style: styleSheet.icon
  }, /*#__PURE__*/React.createElement(View, {
    style: [styleSheet.iconContent, {
      backgroundColor: iconBackgroundColor
    }]
  }, renderIcon)) : null, /*#__PURE__*/React.createElement(View, {
    style: contentStyles
  }, children));
};
export default Modal;
//# sourceMappingURL=index.native.js.map