import React, { ReactNode } from 'react'; import { useTheme } from '../../theme/ThemeProvider'; import { Box } from '../Box'; import { Text } from '../Text'; import { TouchableComponent } from '../TouchableComponent'; import InfoIcon from '../../icons/InfoIcon'; import { CardContainer } from '../CardContainer'; import type { ResponsiveValue } from '@shopify/restyle'; import type { Theme } from '../../theme/theme'; interface CardProps { title: string; titleVariant?: ResponsiveValue; subtitle?: string; subtitleVariant?: ResponsiveValue; onPress?: () => void; disabled?: boolean; onInfoPress?: () => void; titleIcon?: ReactNode; rightIcon?: ReactNode; } interface internalCardProps extends CardProps { width: string; relativePosition: 'left' | 'middle' | 'right'; } type CardGroupProps = React.ComponentProps & { leftComponent: CardProps; middleComponent?: CardProps; rightComponent: CardProps; width?: string | number; height?: string | number; withCardContainer?: boolean; }; export const CardGroup = ({ leftComponent, middleComponent, rightComponent, width = '100%', withCardContainer = true, ...props }: CardGroupProps) => { const { fonts } = useTheme(); const Card = ({ title, titleVariant = 'H3', subtitle, subtitleVariant = 'label', width: widthCard, onPress, disabled, onInfoPress, relativePosition, rightIcon, titleIcon, }: internalCardProps) => { return ( {onInfoPress && relativePosition === 'left' ? ( ) : null} {!!titleIcon && {titleIcon}} {` ${title}`} {subtitle && ( {subtitle} )} {onInfoPress && relativePosition === 'right' ? ( {rightIcon || } ) : null} ); }; const Separator = () => ( ); const CardGroupComponent = ({ ...propsRest }) => ( {leftComponent && ( )} {middleComponent && } {middleComponent && ( )} {rightComponent && ( )} ); if (withCardContainer) return ( ); return ; };