import { Text } from '@/aesthetics/Text'; import { font, radius, spacing, useColors } from '@/aesthetics/styles'; import { getAllIngredients, isIngredientEnabled } from '@/add-log/utils/ingredients'; import type { StagedFoodLog } from '@/types/foodlog'; import { ActivityIndicator, Pressable, StyleSheet, View } from 'react-native'; import Animated, { FadeIn } from 'react-native-reanimated'; type IngredientPillListProps = { log: StagedFoodLog; onToggle: (logId: string, ingredient: string, isEnabled: boolean) => void; }; const STAGGER_MS = 60; export function IngredientPillList({ log, onToggle }: IngredientPillListProps) { const c = useColors(); const allIngredients = getAllIngredients(log); const isStreaming = log.detectionPhase === 'streaming'; if (log.regeneratingIngredients) { const humanTouched = [...log.userEnabledIngredients, ...log.userDisabledIngredients]; if (humanTouched.length === 0) { return ( ); } return ( {log.userEnabledIngredients.map(ingredient => ( onToggle(log.id, ingredient, true)} > {ingredient} ))} {log.userDisabledIngredients.map(ingredient => ( onToggle(log.id, ingredient, false)} > {ingredient} ))} ); } if (allIngredients.length === 0) return null; return ( {allIngredients.map((ingredient, i) => { const enabled = isIngredientEnabled(log, ingredient); const pill = ( onToggle(log.id, ingredient, enabled)} > {ingredient} ); if (isStreaming) { return ( {pill} ); } return pill; })} ); } const styles = StyleSheet.create({ container: { marginTop: spacing.sm }, regeneratingRow: { marginTop: spacing.sm, height: 24, justifyContent: 'center' }, pillsRow: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.xs }, pill: { paddingHorizontal: spacing.md, paddingVertical: spacing.xs, borderRadius: radius.pill, }, pillText: { fontSize: font.xs }, pillTextOff: { fontSize: font.xs, textDecorationLine: 'line-through' }, });