- 修改 app.json,禁用平板支持以优化用户体验 - 在 package.json 和 package-lock.json 中新增 react-native-toast-message 依赖,支持消息提示功能 - 在多个组件中集成 Toast 组件,提升用户交互反馈 - 更新训练计划相关逻辑,优化状态管理和数据处理 - 调整样式以适应新功能的展示和交互
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import { ThemedView } from '@/components/ThemedView';
|
|
import { useThemeColor } from '@/hooks/useThemeColor';
|
|
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);
|
|
router.replace('/(tabs)');
|
|
} catch (error) {
|
|
console.error('检查引导状态失败:', error);
|
|
// 如果出现错误,默认显示引导页面
|
|
// setTimeout(() => {
|
|
// router.replace('/onboarding');
|
|
// }, 1000);
|
|
}
|
|
setIsLoading(false);
|
|
};
|
|
|
|
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>
|
|
);
|
|
}
|