import React from "react"; import { StyleSheet, View, ImageSourcePropType, StyleProp, ViewStyle, TextStyle, Pressable, } from "react-native"; import Image from "../components/Image"; import Surface from "../components/Surface"; import { Title, Subtitle, Caption } from "../components/Typography"; import { withTheme } from "@draftbit/theme"; import Config from "../components/Config"; import type { ReadTheme } from "@draftbit/theme"; import type { IconSlot } from "../interfaces/Icon"; const ICON_SIZE = Config.cardIconSize; const ICON_CONTAINER_SIZE = Config.cardIconSize * 2; const ICON_CONTAINER_PADDING = Config.cardIconSize / 2 - 1; const ICON_ELEVATION = Config.cardIconElevation; export const TopRightCircleIcon = withTheme( ({ Icon, icon, theme, onPress, }: { icon: string; theme: ReadTheme; onPress?: () => void; } & IconSlot) => { return ( { return [ { opacity: pressed ? 0.8 : 1, }, ]; }} > ); } ); type Props = { image?: string | ImageSourcePropType; title?: string; subtitle?: string; description?: string; textCentered: boolean; icon?: string; aspectRatio?: number; elevation?: number; numColumns?: number; theme: ReadTheme; titleStyle?: StyleProp; subtitleStyle?: StyleProp; descriptionStyle?: StyleProp; style?: StyleProp; onPress?: () => void; onPressIcon?: () => void; children?: React.ReactNode; } & IconSlot; /** * @deprecated DEPRECATED */ const Card: React.FC> = ({ Icon, image = Config.cardImageUrl, title, subtitle, description, textCentered, icon, aspectRatio = 1.5, elevation = 2, style, onPress, onPressIcon, titleStyle, subtitleStyle, descriptionStyle, theme, children, }) => { const { backgroundColor: bgColor, padding, ...styles } = StyleSheet.flatten(style || {}); const backgroundColor = bgColor ? bgColor : theme.colors.background.base; const innerPadding = padding ? padding : 12; return ( { return [ { opacity: pressed ? 0.8 : 1, }, ]; }} > {title || (title && title !== "") ? ( ) : null} {subtitle || (subtitle && subtitle !== "") ? ( <Subtitle text={subtitle} style={subtitleStyle} /> ) : null} {description || (description && description !== "") ? ( <View style={{ marginTop: 4 }}> <Caption text={description} style={descriptionStyle} /> </View> ) : null} {children} </View> </View> {icon ? ( <TopRightCircleIcon Icon={Icon} icon={icon} onPress={onPressIcon} /> ) : null} </Pressable> </Surface> ); }; export default withTheme(Card);