import React from 'react'; import { Text, Icon, Flex, Button } from 'native-base'; import Unicons from '../Unicons'; import { Pressable } from 'react-native'; interface InfoItemProps { variant: 'button' | 'info'; borderType?: "10" | "00" | "01"; type: "location" | "card" | "datetime"; text1?: string; text2?: string; buttonText?: string; } export default function (props: InfoItemProps) { let { borderTopRadius, borderBottomRadius } = getBorderRadiuses(props); let { bgColor, iconName } = getIconBgColorAndIcon(props); let { pt, pb } = getPaddings(props); return {props.text1 || "{{text1}}"} {props.text1 || "{{text2}}"} {props.variant === "button" && {props.buttonText || "{{buttonText}}"} } } function getPaddings(props: InfoItemProps) { let pt = "4"; let pb = "4"; if (props.borderType === "10") { pt = "4" pb = "2" } if (props.borderType === "00") { pt = "2" pb = "2" } if (props.borderType === "01") { pt = "2" pb = "4" } return { pt, pb }; } function getIconBgColorAndIcon(props: InfoItemProps) { switch (props.type) { case "datetime": return { bgColor: "mini_blue", iconName: "calender" } case "location": return { bgColor: "mini_violet", iconName: "map-marker" } case "card": return { bgColor: "mini_cream", iconName: "credit-card" } default: return { bgColor: "mini_blue", iconName: "calender" }; } } function getBorderRadiuses(props: InfoItemProps) { let borderTopRadius = "xl"; let borderBottomRadius = "xl"; if (props.borderType === "10") { borderBottomRadius = "none"; } if (props.borderType === "00") { borderTopRadius = "none"; borderBottomRadius = "none"; } if (props.borderType === "01") { borderTopRadius = "none"; } return { borderTopRadius, borderBottomRadius }; }