import React from 'react'; import { View, FlatList, ActivityIndicator, RefreshControl, StyleSheet, Image } from 'react-native'; import { VideoPlayer } from '@/components/video/video-player'; import { ThemedText } from '@/components/themed-text'; import MaterialIcons from '@expo/vector-icons/MaterialIcons'; import { useColorScheme } from '@/hooks/use-color-scheme'; import type { TemplateGeneration } from '@/lib/api/template-generations'; export function ContentGallery({ generations, isRefreshing, onRefresh, isLoadingMore, hasMore, onLoadMore, }: { generations: TemplateGeneration[]; isRefreshing: boolean; onRefresh: () => void; isLoadingMore: boolean; hasMore: boolean; onLoadMore: () => void; }) { const colorScheme = useColorScheme(); const palette = colorScheme === 'dark' ? darkPalette : lightPalette; const renderItem = ({ item }: { item: TemplateGeneration }) => ( ); const renderFooter = () => { if (isLoadingMore) { return ( ); } return null; }; return ( item.id} columnWrapperStyle={styles.columnWrapper} showsVerticalScrollIndicator={false} refreshControl={ } onEndReached={onLoadMore} onEndReachedThreshold={0.5} /> ); } function ContentItem({ palette, generation, }: { palette: any; generation: TemplateGeneration; }) { const formatDate = (dateString: string) => { const date = new Date(dateString); return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', }); }; const renderMedia = () => { const mediaUrl = generation.resultUrl[0]; if (generation.type === 'IMAGE') { return ( ); } else if (generation.type === 'VIDEO') { return ( ); } return null; }; return ( {renderMedia()} {generation.template.title} {formatDate(generation.createdAt)} {generation.status !== 'completed' && ( {generation.status} )} ); } const darkPalette = { background: '#050505', surface: '#121216', border: '#1D1E24', textPrimary: '#F6F7FA', textSecondary: '#8E9098', accent: '#B7FF2F', }; const lightPalette = { background: '#F7F8FB', surface: '#FFFFFF', border: '#E2E5ED', textPrimary: '#0F1320', textSecondary: '#5E6474', accent: '#405CFF', }; const styles = StyleSheet.create({ columnWrapper: { justifyContent: 'space-between', }, contentItem: { flex: 1, borderRadius: 16, borderWidth: 1, marginBottom: 12, overflow: 'hidden', marginHorizontal: 6, }, mediaContainer: { width: '100%', aspectRatio: 1, backgroundColor: '#000', }, mediaImage: { width: '100%', height: '100%', }, mediaVideo: { width: '100%', height: '100%', }, contentInfo: { padding: 12, }, contentTitle: { fontSize: 15, fontWeight: '600', marginBottom: 8, }, contentMeta: { flexDirection: 'row', alignItems: 'center', }, metaItem: { flexDirection: 'row', alignItems: 'center', marginRight: 12, }, metaText: { fontSize: 12, marginLeft: 4, }, statusBadge: { paddingHorizontal: 8, paddingVertical: 4, borderRadius: 4, backgroundColor: 'rgba(0, 0, 0, 0.1)', }, statusText: { fontSize: 11, fontWeight: '600', textTransform: 'capitalize' as const, }, loadingMoreContainer: { paddingVertical: 20, alignItems: 'center', }, });