"use strict";

exports.__esModule = true;
exports.default = exports.HEADER_HEIGHT = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _index = _interopRequireDefault(require("../../atom/header-back-button/index.native"));
var _templateContext = require("../../template/app-review/template-context");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const HEADER_HEIGHT = exports.HEADER_HEIGHT = 64;
const createStyleSheet = theme => _reactNative.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 = (0, _templateContext.useTemplateContext)();
  const [styleSheet, setStylesheet] = (0, _react.useState)(null);
  const {
    theme
  } = templateContext;
  const {
    children,
    headerBackgroundColor,
    iconBackgroundColor,
    renderIcon,
    contentStyle,
    onClose,
    testID
  } = props;
  (0, _react.useEffect)(() => {
    const _stylesheet = createStyleSheet(theme);
    setStylesheet(_stylesheet);
  }, [theme]);
  if (!styleSheet) {
    return null;
  }
  const contentStyles = [styleSheet.content, contentStyle];
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.container,
    testID: testID
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [styleSheet.header, {
      backgroundColor: headerBackgroundColor
    }]
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    color: theme.colors.gray.dark,
    isFloating: false,
    testID: "close-modal",
    onPress: onClose,
    type: "close"
  })), renderIcon ? /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.icon
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [styleSheet.iconContent, {
      backgroundColor: iconBackgroundColor
    }]
  }, renderIcon)) : null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: contentStyles
  }, children));
};
var _default = exports.default = Modal;
//# sourceMappingURL=index.native.js.map