import { Ionicons } from '@expo/vector-icons'; import { Image as ExpoImage } from 'expo-image'; import { LinearGradient } from 'expo-linear-gradient'; import { memo } from 'react'; import { FlatList, ListRenderItemInfo, Pressable, Image as RNImage, StyleProp, StyleSheet, Text, View, ViewStyle, } from 'react-native'; export type CommunityItem = { id: string; title: string; image: string; chip: string; actionLabel: string; width?: number; height?: number; }; type CommunityGridProps = { items: CommunityItem[]; onPressCard?: (item: CommunityItem) => void; onPressAction?: (item: CommunityItem) => void; }; const EMPTY_ITEM: CommunityItem = { id: 'empty', title: '', image: '', chip: '', actionLabel: '', }; export function CommunityGrid({ items, onPressCard, onPressAction }: CommunityGridProps) { const renderItem = ({ item, index }: ListRenderItemInfo) => { const isEmpty = item.id === 'empty'; const isLeftColumn = index % 2 === 0; return ( {isEmpty ? ( ) : ( )} ); }; const data = items.length === 0 ? [EMPTY_ITEM, EMPTY_ITEM] : items.length === 1 ? [...items, EMPTY_ITEM] : items.slice(0, 4); return ( item.id} numColumns={2} scrollEnabled={false} columnWrapperStyle={styles.row} contentContainerStyle={styles.contentContainer} /> ); } type CommunityCardProps = { item: CommunityItem; style?: StyleProp; onPressCard?: (item: CommunityItem) => void; onPressAction?: (item: CommunityItem) => void; }; const CommunityCard = memo(({ item, style, onPressCard, onPressAction }: CommunityCardProps) => { const aspectRatio = item.width && item.height ? item.width / item.height : 9 / 16; return ( onPressCard?.(item)} style={[styles.card, style]}> {item.title} onPressAction?.(item)} /> ); }); CommunityCard.displayName = 'CommunityCard'; type ChipProps = { label: string; }; const Chip = memo(({ label }: ChipProps) => { return ( {label} ); }); Chip.displayName = 'CommunityChip'; type ActionButtonProps = { label: string; onPress: () => void; }; const ActionButton = memo(({ label, onPress }: ActionButtonProps) => { return ( [styles.button, pressed && styles.buttonPressed]}> {label} ); }); ActionButton.displayName = 'CommunityActionButton'; const styles = StyleSheet.create({ contentContainer: { paddingBottom: 24, }, row: { justifyContent: 'space-between', marginBottom: 18, }, cardWrapper: { flex: 1, }, cardLeft: { marginRight: 8, }, cardRight: { marginLeft: 8, }, emptyCard: { backgroundColor: 'transparent', borderRadius: 20, }, card: { backgroundColor: '#2E3031', borderRadius: 20, padding: 0, borderWidth: 1, borderColor: '#1B1D24', }, imageWrapper: { position: 'relative', borderRadius: 16, overflow: 'hidden', marginBottom: 0, }, cardImage: { width: '100%', height: undefined, }, imageGradient: { position: 'absolute', left: 0, right: 0, bottom: 0, height: 88, }, cardTitle: { position: 'absolute', left: 16, bottom: 18, fontSize: 14, letterSpacing: 1, fontWeight: '700', color: '#F5F8FF', textTransform: 'uppercase', }, chip: { position: 'absolute', top: 14, right: 14, backgroundColor: 'rgba(27, 43, 78, 0.92)', borderRadius: 16, paddingHorizontal: 12, paddingVertical: 5, flexDirection: 'row', alignItems: 'center', }, chipIcon: { marginLeft: 6, }, chipText: { color: '#E4EBFF', fontSize: 12, fontWeight: '600', letterSpacing: 0.5, }, button: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingVertical: 14, borderRadius: 16, borderWidth: 0, }, buttonPressed: { opacity: 0.85, }, buttonIcon: { width: 18, height: 18, marginRight: 8, }, buttonText: { fontSize: 14, fontWeight: '700', color: '#C7FF00', }, });