import React from 'react'; import {View, Image, StyleSheet, Text} from 'react-native'; import {SwipeableListItemAvatarProps} from './types'; import {useTheme, ColorsScheme} from '../../theme/ThemeContext'; import PlayyText from '../PlayyText/PlayyText'; /** * Avatar section of SwipeableListItem * Accepts all Image props plus custom size, style, and fallbackName * * @example * ```tsx * // With image * * * // Fallback with initials * * ``` */ export const SwipeableListItemAvatar: React.FC = ({ source, fallbackName, size = 56, style, ...imageProps }) => { const {colors} = useTheme(); const styles = themedStyle(colors); // Get initials from fallbackName const getInitials = (name: string): string => { const parts = name.trim().split(' ').filter(Boolean); if (parts.length === 0) return '?'; if (parts.length === 1) return parts[0][0].toUpperCase(); return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase(); }; return ( {source ? ( ) : ( {fallbackName && ( {getInitials(fallbackName)} )} )} ); }; const themedStyle = (colors: ColorsScheme) => StyleSheet.create({ avatarContainer: { marginRight: 12.66, }, avatar: { width: 56, height: 56, borderRadius: 50, }, avatarPlaceholder: { backgroundColor: colors.fill_tertiary, justifyContent: 'center', alignItems: 'center', }, });