feat(auth): 为未登录用户添加登录引导界面
为目标页面、营养记录、食物添加等功能添加登录状态检查和引导界面,确保用户在未登录状态下能够获得清晰的登录提示和指引。 - 在目标页面添加精美的未登录引导界面,包含渐变背景和登录按钮 - 为食物记录相关组件添加登录状态检查,未登录时自动跳转登录页面 - 重构血氧饱和度卡片为独立数据获取,移除对外部数据依赖 - 移除个人页面的实验性SwiftUI组件,统一使用原生TouchableOpacity - 清理统计页面和营养记录页面的冗余代码和未使用变量
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { AnimatedNumber } from '@/components/AnimatedNumber';
|
||||
import { ROUTES } from '@/constants/Routes';
|
||||
import { useAuthGuard } from '@/hooks/useAuthGuard';
|
||||
import { NutritionSummary } from '@/services/dietRecords';
|
||||
import { triggerLightHaptic } from '@/utils/haptics';
|
||||
import { NutritionGoals, calculateRemainingCalories } from '@/utils/nutrition';
|
||||
import { calculateRemainingCalories } from '@/utils/nutrition';
|
||||
import dayjs from 'dayjs';
|
||||
import { router } from 'expo-router';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
@@ -14,8 +15,6 @@ const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
||||
|
||||
export type NutritionRadarCardProps = {
|
||||
nutritionSummary: NutritionSummary | null;
|
||||
/** 营养目标 */
|
||||
nutritionGoals?: NutritionGoals;
|
||||
/** 基础代谢消耗的卡路里 */
|
||||
burnedCalories?: number;
|
||||
/** 基础代谢率 */
|
||||
@@ -25,8 +24,6 @@ export type NutritionRadarCardProps = {
|
||||
|
||||
/** 动画重置令牌 */
|
||||
resetToken?: number;
|
||||
/** 餐次点击回调 */
|
||||
onMealPress?: (mealType: 'breakfast' | 'lunch' | 'dinner' | 'snack') => void;
|
||||
};
|
||||
|
||||
// 简化的圆环进度组件
|
||||
@@ -97,16 +94,15 @@ const SimpleRingProgress = ({
|
||||
|
||||
export function NutritionRadarCard({
|
||||
nutritionSummary,
|
||||
nutritionGoals,
|
||||
burnedCalories = 1618,
|
||||
basalMetabolism,
|
||||
activeCalories,
|
||||
|
||||
resetToken,
|
||||
onMealPress
|
||||
}: NutritionRadarCardProps) {
|
||||
const [currentMealType] = useState<'breakfast' | 'lunch' | 'dinner' | 'snack'>('breakfast');
|
||||
|
||||
const { pushIfAuthedElseLogin } = useAuthGuard()
|
||||
|
||||
const nutritionStats = useMemo(() => {
|
||||
return [
|
||||
{ label: '热量', value: nutritionSummary ? `${Math.round(nutritionSummary.totalCalories)} 千卡` : '0 千卡', color: '#FF6B6B' },
|
||||
@@ -225,7 +221,7 @@ export function NutritionRadarCard({
|
||||
style={styles.foodOptionItem}
|
||||
onPress={() => {
|
||||
triggerLightHaptic();
|
||||
router.push(`/food/camera?mealType=${currentMealType}`);
|
||||
pushIfAuthedElseLogin(`/food/camera?mealType=${currentMealType}`);
|
||||
}}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
@@ -242,7 +238,7 @@ export function NutritionRadarCard({
|
||||
style={styles.foodOptionItem}
|
||||
onPress={() => {
|
||||
triggerLightHaptic();
|
||||
router.push(`${ROUTES.FOOD_LIBRARY}?mealType=${currentMealType}`);
|
||||
pushIfAuthedElseLogin(`${ROUTES.FOOD_LIBRARY}?mealType=${currentMealType}`);
|
||||
}}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
@@ -259,7 +255,7 @@ export function NutritionRadarCard({
|
||||
style={styles.foodOptionItem}
|
||||
onPress={() => {
|
||||
triggerLightHaptic();
|
||||
router.push(`${ROUTES.VOICE_RECORD}?mealType=${currentMealType}`);
|
||||
pushIfAuthedElseLogin(`${ROUTES.VOICE_RECORD}?mealType=${currentMealType}`);
|
||||
}}
|
||||
activeOpacity={0.7}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user