- 新增 BMI 计算工具,支持用户输入体重和身高计算 BMI 值,并根据结果提供分类和建议 - 在训练计划中集成排课功能,允许用户选择和安排训练动作 - 更新个人信息页面,添加出生日期字段,支持用户完善个人资料 - 优化训练计划卡片样式,提升用户体验 - 更新相关依赖,确保项目兼容性和功能完整性
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import { ThemedView } from '@/components/ThemedView';
|
|
import { useThemeColor } from '@/hooks/useThemeColor';
|
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
import { router } from 'expo-router';
|
|
import React, { useEffect, useState } from 'react';
|
|
import { ActivityIndicator, View } from 'react-native';
|
|
|
|
const ONBOARDING_COMPLETED_KEY = '@onboarding_completed';
|
|
|
|
export default function SplashScreen() {
|
|
const backgroundColor = useThemeColor({}, 'background');
|
|
const primaryColor = useThemeColor({}, 'primary');
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
checkOnboardingStatus();
|
|
}, []);
|
|
|
|
const checkOnboardingStatus = async () => {
|
|
try {
|
|
const onboardingCompleted = await AsyncStorage.getItem(ONBOARDING_COMPLETED_KEY);
|
|
|
|
if (onboardingCompleted === 'true') {
|
|
router.replace('/(tabs)');
|
|
} else {
|
|
router.replace('/onboarding');
|
|
}
|
|
setIsLoading(false);
|
|
} catch (error) {
|
|
console.error('检查引导状态失败:', error);
|
|
// 如果出现错误,默认显示引导页面
|
|
setTimeout(() => {
|
|
router.replace('/onboarding');
|
|
setIsLoading(false);
|
|
}, 1000);
|
|
}
|
|
};
|
|
|
|
if (!isLoading) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ThemedView style={{
|
|
flex: 1,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
backgroundColor
|
|
}}>
|
|
<View style={{
|
|
width: 80,
|
|
height: 80,
|
|
borderRadius: 40,
|
|
backgroundColor: primaryColor,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
marginBottom: 20,
|
|
}}>
|
|
|
|
</View>
|
|
<ActivityIndicator size="large" color={primaryColor} />
|
|
</ThemedView>
|
|
);
|
|
}
|