UNPKG

expo-modal-popup

Version:

Modal component for expo react native

76 lines (75 loc) 3.11 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ModalPopup = void 0; var jsx_runtime_1 = require("react/jsx-runtime"); var vector_icons_1 = require("@expo/vector-icons"); var react_native_1 = require("react-native"); var TypeEnum_1 = require("./TypeEnum"); var ModalPopup = function (_a) { var isOpen = _a.isOpen, setIsOpen = _a.setIsOpen, errorMsg = _a.errorMsg, type = _a.type; var ModalIcon = function () { switch (type) { case TypeEnum_1.TypeEnum.error: return (0, jsx_runtime_1.jsx)(vector_icons_1.MaterialIcons, { name: "error-outline", size: 24, color: "red" }); case TypeEnum_1.TypeEnum.warning: return (0, jsx_runtime_1.jsx)(vector_icons_1.AntDesign, { name: "warning", size: 20, color: "#AB7A00" }); case TypeEnum_1.TypeEnum.success: return (0, jsx_runtime_1.jsx)(vector_icons_1.AntDesign, { name: "checkcircleo", size: 20, color: "green" }); default: return (0, jsx_runtime_1.jsx)(react_native_1.View, {}); } }; var modalColor = function () { switch (type) { case TypeEnum_1.TypeEnum.error: return { color: "red" }; case TypeEnum_1.TypeEnum.warning: return { color: "#AB7A00" }; case TypeEnum_1.TypeEnum.success: return { color: "green" }; default: return { color: "black" }; } }; return ((0, jsx_runtime_1.jsx)(react_native_1.Modal, __assign({ animationType: "fade", transparent: true, visible: isOpen, onRequestClose: function () { setIsOpen(false); } }, { children: (0, jsx_runtime_1.jsx)(react_native_1.Pressable, __assign({ style: styles.centeredView, onPress: function () { setIsOpen(false); } }, { children: (0, jsx_runtime_1.jsxs)(react_native_1.View, __assign({ style: styles.modalView }, { children: [ModalIcon(), (0, jsx_runtime_1.jsx)(react_native_1.Text, __assign({ style: [{ marginLeft: 5 }, modalColor()] }, { children: errorMsg }))] })) })) }))); }; exports.ModalPopup = ModalPopup; var styles = react_native_1.StyleSheet.create({ centeredView: { flex: 1, justifyContent: "flex-end", alignItems: "center", marginTop: 22, }, modalView: { margin: 10, backgroundColor: "white", borderRadius: 20, padding: 15, alignItems: "center", shadowColor: "#000", shadowOffset: { width: 0, height: 2, }, shadowOpacity: 0.25, shadowRadius: 4, elevation: 5, flexDirection: "row", }, });