- 将应用版本更新至 1.0.3,修改相关配置文件 - 强制全局使用浅色主题,确保一致的用户体验 - 在训练计划功能中新增激活计划的 API 接口,支持用户激活训练计划 - 优化打卡功能,支持自动同步打卡记录至服务器 - 更新样式以适应新功能的展示和交互
61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
import { DefaultTheme, ThemeProvider } from '@react-navigation/native';
|
|
import { useFonts } from 'expo-font';
|
|
import { Stack } from 'expo-router';
|
|
import { StatusBar } from 'expo-status-bar';
|
|
import 'react-native-reanimated';
|
|
|
|
import { useAppDispatch } from '@/hooks/redux';
|
|
import { useColorScheme } from '@/hooks/useColorScheme';
|
|
import { clearAiCoachSessionCache } from '@/services/aiCoachSession';
|
|
import { store } from '@/store';
|
|
import { rehydrateUser } from '@/store/userSlice';
|
|
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
|
|
function Bootstrapper({ children }: { children: React.ReactNode }) {
|
|
const dispatch = useAppDispatch();
|
|
React.useEffect(() => {
|
|
dispatch(rehydrateUser());
|
|
// 冷启动时清空 AI 教练会话缓存
|
|
clearAiCoachSessionCache();
|
|
}, [dispatch]);
|
|
return <>{children}</>;
|
|
}
|
|
|
|
export default function RootLayout() {
|
|
const colorScheme = useColorScheme();
|
|
const [loaded] = useFonts({
|
|
SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),
|
|
});
|
|
|
|
if (!loaded) {
|
|
// Async font loading only occurs in development.
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Provider store={store}>
|
|
<Bootstrapper>
|
|
<ThemeProvider value={DefaultTheme}>
|
|
<Stack screenOptions={{ headerShown: false }}>
|
|
<Stack.Screen name="onboarding" />
|
|
<Stack.Screen name="(tabs)" />
|
|
<Stack.Screen name="challenge" options={{ headerShown: false }} />
|
|
<Stack.Screen name="training-plan" options={{ headerShown: false }} />
|
|
<Stack.Screen name="profile/edit" />
|
|
<Stack.Screen name="profile/goals" options={{ headerShown: false }} />
|
|
<Stack.Screen name="ai-coach-chat" options={{ headerShown: false }} />
|
|
<Stack.Screen name="ai-posture-assessment" />
|
|
<Stack.Screen name="auth/login" options={{ headerShown: false }} />
|
|
<Stack.Screen name="legal/user-agreement" options={{ headerShown: true, title: '用户协议' }} />
|
|
<Stack.Screen name="legal/privacy-policy" options={{ headerShown: true, title: '隐私政策' }} />
|
|
<Stack.Screen name="article/[id]" options={{ headerShown: false }} />
|
|
<Stack.Screen name="+not-found" />
|
|
</Stack>
|
|
<StatusBar style="dark" />
|
|
</ThemeProvider>
|
|
</Bootstrapper>
|
|
</Provider>
|
|
);
|
|
}
|