import React, { ReactNode } from 'react'; import type { GestureResponderEvent } from 'react-native'; import type { ResponsiveValue } from '@shopify/restyle'; import { Warning } from 'phosphor-react-native'; import { TouchableComponent } from '../TouchableComponent'; import type { Theme } from '../../theme/theme'; import { useTheme } from '../../theme/ThemeProvider'; import { Box } from '../Box'; import { Text } from '../Text'; interface CardProps { customComponent?: ReactNode; iconAlign?: 'center' | 'flex-end' | 'flex-start'; subtitle?: string; subtitleColor?: ResponsiveValue; subtitleVariant?: ResponsiveValue; subtitleWeight?: 'regular' | 'bold'; title?: string; titleColor?: ResponsiveValue; titleVariant?: ResponsiveValue; titleWeight?: 'regular' | 'bold'; type: 'success' | 'danger' | 'warning'; } type Props = React.ComponentProps & CardProps & { backgroundColor?: string; bg?: string; onLongPress?: (event: GestureResponderEvent) => void; onPress?: (event: GestureResponderEvent) => void; }; /** * * @example * ### CardAlert - success | danger | warning * * ```js * * ``` * */ export const CardAlert = ({ backgroundColor = 'white', bg, customComponent, iconAlign = 'center', onLongPress, onPress, subtitle, subtitleColor, subtitleVariant = 'label', subtitleWeight = 'regular', title, titleColor, titleVariant = 'body', titleWeight = 'bold', type, ...props }: Props) => { const { colors, fonts } = useTheme(); let color: ResponsiveValue; let iconColor: string | undefined; switch (type) { case 'success': color = 'blueJeans'; iconColor = colors.blueJeans; break; case 'danger': color = 'chiperBrandRed'; iconColor = colors.chiperBrandRed; break; case 'warning': color = 'brightYellow'; iconColor = colors.brightYellow; break; } const CardAlertComponent = () => { return ( {!!title && ( {title} )} {!!subtitle && ( {subtitle} )} {!!customComponent && {customComponent}} ); }; if (onPress || onLongPress) { return ( ); } return ; };