import { useCallback } from "react"; import { Dimensions, FlatList, Image, Pressable, StyleSheet, Text, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useRouter } from "expo-router"; import Animated, { FadeInDown } from "react-native-reanimated"; import { Plus, ImageSquare } from "phosphor-react-native"; import { GlassCard, GlassButton } from "@/components/glass"; import { useWallpaperStore } from "@/stores/wallpaper.store"; import { colors, typography, spacing, layout } from "@/theme"; import { ANIMATION_META, type WallpaperConfig } from "@/types/wallpaper"; const { width: SCREEN_WIDTH } = Dimensions.get("window"); const CARD_SIZE = (SCREEN_WIDTH - layout.screenPadding * 2 - spacing.md) / 2; export default function HomeScreen() { const insets = useSafeAreaInsets(); const router = useRouter(); const savedWallpapers = useWallpaperStore((s) => s.savedWallpapers); const handleNewWallpaper = useCallback(() => { router.push("/picker"); }, [router]); const handleOpenWallpaper = useCallback( (config: WallpaperConfig) => { const store = useWallpaperStore.getState(); store.setSourceImage(config.sourceUri); store.setAnimation(config.animation); Object.entries(config.uniforms).forEach(([key, value]) => { store.setUniform(key, value); }); router.push(`/editor/${config.id}`); }, [router] ); return ( {/* Header */} Lively Vos fonds d'écran animés {/* Content */} {savedWallpapers.length === 0 ? ( ) : ( item.id} contentContainerStyle={styles.grid} columnWrapperStyle={styles.row} showsVerticalScrollIndicator={false} ListHeaderComponent={ Récentes {savedWallpapers.length} création{savedWallpapers.length > 1 ? "s" : ""} } renderItem={({ item, index }) => ( handleOpenWallpaper(item)} /> )} /> )} {/* Floating CTA */} {savedWallpapers.length > 0 && ( )} ); } function EmptyState({ onPress }: { onPress: () => void }) { return ( Donnez vie à vos photos Choisissez une image et appliquez{"\n"}une animation en quelques taps ); } function WallpaperCard({ config, index, onPress, }: { config: WallpaperConfig; index: number; onPress: () => void; }) { const meta = ANIMATION_META[config.animation]; return ( {meta.label} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: colors.background, paddingHorizontal: layout.screenPadding, }, header: { marginBottom: spacing.lg, }, headerRow: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", }, sectionHeader: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", marginBottom: spacing.md, }, grid: { paddingBottom: 160, }, row: { gap: spacing.md, }, emptyContainer: { flex: 1, justifyContent: "center", paddingHorizontal: spacing.md, }, emptyContent: { alignItems: "center", }, cardImage: { width: CARD_SIZE, height: CARD_SIZE * 1.4, borderRadius: 24, }, cardOverlay: { position: "absolute", bottom: 0, left: 0, right: 0, padding: 12, borderBottomLeftRadius: 24, borderBottomRightRadius: 24, backgroundColor: "rgba(0, 0, 0, 0.4)", }, cardLabel: { ...typography.caption, color: colors.text.primary, fontWeight: "600", }, fabContainer: { position: "absolute", left: layout.screenPadding, right: layout.screenPadding, }, });