"use strict";

import { useContext } from 'react';
import { TouchableOpacity, View } from 'react-native';
import { ApplicationContext } from "../Context/index.js";
import { Colors, Spacing, Styles } from "../Consts/index.js";
import { Divider } from "../Divider/index.js";
import { Icon } from "../Icon/index.js";
import { SizedBox } from "../SizedBox/index.js";
import { Text } from "../Text/index.js";
import styles from "./styles.js";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
const Toast = ({
  type,
  icon,
  message = 'Toast Message',
  action
}) => {
  const {
    theme,
    translate
  } = useContext(ApplicationContext);
  const getBackgroundColor = () => {
    switch (type) {
      case 'success':
        return theme.colors.success.default;
      case 'warning':
        return theme.colors.warning.default;
      default:
        return Colors.black_04;
    }
  };
  return /*#__PURE__*/_jsxs(View, {
    style: [styles.container, {
      backgroundColor: getBackgroundColor()
    }],
    children: [/*#__PURE__*/_jsx(SizedBox, {
      width: Spacing.M
    }), !!icon && /*#__PURE__*/_jsxs(View, {
      style: Styles.row,
      children: [/*#__PURE__*/_jsx(Icon, {
        name: icon,
        size: 24,
        color: Colors.white
      }), /*#__PURE__*/_jsx(SizedBox, {
        width: Spacing.S
      })]
    }), /*#__PURE__*/_jsx(Text, {
      typography: 'subhead',
      color: Colors.white,
      style: Styles.flex,
      children: translate(message)
    }), action?.title && /*#__PURE__*/_jsxs(_Fragment, {
      children: [/*#__PURE__*/_jsx(View, {
        style: Styles.paddingVerticalS,
        children: /*#__PURE__*/_jsx(Divider, {
          size: 0.5,
          direction: 'vertical',
          color: Colors.white
        })
      }), /*#__PURE__*/_jsx(TouchableOpacity, {
        style: Styles.paddingHorizontalM,
        onPress: action.onPress,
        children: /*#__PURE__*/_jsx(Text, {
          typography: 'caption2',
          fontWeight: 'bold',
          color: Colors.white,
          numberOfLines: 2,
          children: action?.title
        })
      })]
    })]
  });
};
export { Toast };
//# sourceMappingURL=index.js.map