feat: 支持食物详情弹窗

This commit is contained in:
richarjiang
2025-08-28 19:24:22 +08:00
parent 6551757ca8
commit c15a9176f4
7 changed files with 664 additions and 233 deletions

View File

@@ -7,7 +7,7 @@ import { router } from 'expo-router';
import React, { useMemo, useState } from 'react';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { RadarCategory, RadarChart } from './RadarChart';
import { FoodItem, FoodLibraryModal } from './model/food/FoodLibraryModal';
export type NutritionRadarCardProps = {
nutritionSummary: NutritionSummary | null;
@@ -38,7 +38,6 @@ export function NutritionRadarCard({
resetToken,
onMealPress
}: NutritionRadarCardProps) {
const [showFoodLibrary, setShowFoodLibrary] = useState(false);
const [currentMealType, setCurrentMealType] = useState<'breakfast' | 'lunch' | 'dinner' | 'snack'>('breakfast');
const radarValues = useMemo(() => {
// 基于推荐日摄入量计算分数
@@ -115,12 +114,7 @@ export function NutritionRadarCard({
};
const handleAddFood = () => {
setShowFoodLibrary(true);
};
const handleSelectFood = (food: FoodItem) => {
console.log('选择了食物:', food);
// 这里可以添加将食物添加到营养记录的逻辑
router.push(`/food-library?mealType=${currentMealType}`);
};
return (
@@ -193,13 +187,7 @@ export function NutritionRadarCard({
</View>
</View>
{/* 食物库弹窗 */}
<FoodLibraryModal
visible={showFoodLibrary}
onClose={() => setShowFoodLibrary(false)}
onSelectFood={handleSelectFood}
mealType={currentMealType}
/>
</TouchableOpacity>
);
}