import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Modal from 'react-native-modal';
import { NovaSolidStatusClose as CloseIcon } from '@coorpacademy/nova-icons';
import { useTemplateContext } from '../../template/app-review/template-context';
import Touchable from '../../hoc/touchable/index.native';
const createStyleSheet = (brandTheme, theme) => StyleSheet.create({
  popin: {
    position: 'absolute',
    top: 0,
    bottom: 0,
    justifyContent: 'center',
    alignItems: 'center'
  },
  content: {
    backgroundColor: '#fff',
    justifyContent: 'space-between',
    alignItems: 'center',
    borderRadius: 8,
    paddingVertical: 24
  },
  iconWrapper: {
    width: 100,
    height: 100,
    backgroundColor: '#FFEFEB',
    justifyContent: 'center',
    borderRadius: 60,
    marginBottom: 12
  },
  icon: {
    alignSelf: 'center',
    width: 60,
    height: 60,
    fill: brandTheme.colors?.primary
  },
  title: {
    textAlign: 'center',
    lineHeight: 24,
    fontWeight: '700',
    fontSize: 20,
    marginHorizontal: 24,
    marginVertical: 12
  },
  description1: {
    textAlign: 'center',
    lineHeight: 19,
    fontWeight: '300',
    fontSize: 14,
    marginHorizontal: 24,
    marginVertical: 12
  },
  description2: {
    textAlign: 'center',
    lineHeight: 19,
    fontWeight: '700',
    fontSize: 16,
    paddingHorizontal: 48,
    marginVertical: 12
  },
  button: {
    height: 44,
    backgroundColor: brandTheme.colors?.primary,
    borderRadius: 7,
    justifyContent: 'center',
    padding: 12,
    paddingVertical: 12,
    marginTop: 12
  },
  buttonText: {
    alignSelf: 'center',
    color: '#FFFFFF',
    fontWeight: theme.fontWeight.bold,
    fontFamily: 'System',
    fontSize: 14,
    lineHeight: 20
  },
  closeButton: {
    position: 'absolute',
    top: 0,
    right: 0,
    width: 45,
    height: 45,
    padding: 10,
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  closeIcon: {
    width: '100%',
    height: '100%',
    fill: '#aeaeae'
  }
});
const PopinIntro = props => {
  const templateContext = useTemplateContext();
  const [styleSheet, setStylesheet] = useState(null);
  const {
    brandTheme,
    theme
  } = templateContext;
  const {
    isVisible,
    onValidate,
    onCancel,
    locales,
    Icon
  } = props;
  useEffect(() => {
    const _stylesheet = createStyleSheet(brandTheme, theme);
    setStylesheet(_stylesheet);
  }, [brandTheme, theme]);
  if (!styleSheet) {
    return null;
  }
  return /*#__PURE__*/React.createElement(Modal, {
    isVisible: isVisible,
    style: styleSheet.popin,
    testID: "intro-popin"
  }, /*#__PURE__*/React.createElement(View, {
    style: styleSheet.content
  }, Icon ? /*#__PURE__*/React.createElement(View, {
    style: styleSheet.iconWrapper
  }, /*#__PURE__*/React.createElement(Icon, {
    style: styleSheet.icon
  })) : null, /*#__PURE__*/React.createElement(Text, {
    style: styleSheet.title
  }, locales.title), /*#__PURE__*/React.createElement(Text, {
    style: styleSheet.description1
  }, locales.description1), /*#__PURE__*/React.createElement(Text, {
    style: styleSheet.description2
  }, locales.description2), /*#__PURE__*/React.createElement(Touchable, {
    style: styleSheet.button,
    onPress: onValidate,
    testID: "intro-popin-validate-button"
  }, /*#__PURE__*/React.createElement(Text, {
    style: styleSheet.buttonText
  }, locales.cta)), /*#__PURE__*/React.createElement(Touchable, {
    style: styleSheet.closeButton,
    onPress: onCancel,
    testID: "intro-popin-cancel-button"
  }, /*#__PURE__*/React.createElement(CloseIcon, {
    style: styleSheet.closeIcon
  }))));
};
export default PopinIntro;
//# sourceMappingURL=index.native.js.map