import React, { useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import AppNavigator from './src/navigation/AppNavigator';

import { TasksProvider } from './src/context/TasksContext';
import { ThemeProvider } from '@rneui/themed';
import { clearCachedConfig } from './src/services/configService';

export default function App() {
  useEffect(() => {
    const clearCacheOnStart = async () => {
      console.log('正在清除缓存的配置文件...');
      await clearCachedConfig();
      console.log('缓存已清除，将使用最新的 config.json。');
    };

    clearCacheOnStart();
  }, []);

  return (
    <ThemeProvider>
      <TasksProvider>
        <NavigationContainer>
          <AppNavigator />
        </NavigationContainer>
      </TasksProvider>
    </ThemeProvider>
  );
}
