import React, { ReactNode } from 'react'; import { Image, TextProps, View, ViewProps } from 'react-native'; import { createBox, createText } from '@shopify/restyle'; import { TouchableComponent } from '../TouchableComponent'; import { Box } from '../Box'; import { Text } from '../Text'; import { useTheme } from '../../theme/ThemeProvider'; import { BasicInput } from '../BasicInput'; import type { Theme } from '../../theme/theme'; type ProductProps = { image: string; referenceName: string; brand: string; sku: number | string; packaging: string; quantity: number; selectedQuantity?: number; extraInfo?: string; }; type StyleAndLogicProps = { onPress?: () => void; onLongPressOnImage?: () => void; onChangeInput?: (text: string) => void; children?: ReactNode; icon?: ReactNode; height?: number | string; rightContent?: ReactNode; mainSize?: number; titleLines?: number; skuVariant?: 'warning' | 'muted'; borderRadius?: number; }; type CardProps = ProductProps & StyleAndLogicProps; const ViewComponent = createBox( View ); const TextComponent = createText( Text ); export const VivoProductCard = ({ onPress, onLongPressOnImage, onChangeInput, image, referenceName, brand, sku, skuVariant, packaging, quantity, selectedQuantity, children, icon, height, rightContent, extraInfo, borderRadius = 0, mainSize = 45, titleLines = 2, }: CardProps) => { const { fonts } = useTheme(); const returnValue = () => { if (selectedQuantity) { return `${selectedQuantity}`; } else if (quantity) { return `${quantity}`; } return ''; }; const skuBg = () => { switch (skuVariant) { case 'warning': return '#FCF4DE'; case 'muted': return '#DDDFE8'; default: return undefined; } }; const skuColor = () => { switch (skuVariant) { case 'warning': return '#FD9535'; case 'muted': return '#666A8F'; default: return undefined; } }; return ( {referenceName} {!!brand && ( {brand} )} {packaging} {sku} {!!extraInfo && ( {extraInfo} )} {rightContent ? null : ( onChangeInput ? onChangeInput(text) : null } height="100%" keyboardType="numeric" value={returnValue()} /> {icon} {!!children && children} )} {rightContent} ); };