34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
// pages/home/index.tsx
|
||
import { useAuth } from '@/components/AuthProvider';
|
||
import { useTheme } from '@/components/ThemeContext';
|
||
import { FilterProvider } from '@/components/ui/FilterContext';
|
||
import { CustomHeader } from '@/components/ui/Header';
|
||
import HomeScreen from '@/screens/home/ui/HomeScreen';
|
||
import { router } from 'expo-router';
|
||
import { useEffect } from 'react';
|
||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||
|
||
export default function Index() {
|
||
const { isDark } = useTheme();
|
||
const { isAuthenticated, isLoading } = useAuth();
|
||
|
||
useEffect(() => {
|
||
if (!isLoading && !isAuthenticated) {
|
||
router.replace('/(auth)');
|
||
}
|
||
}, [isAuthenticated, isLoading]);
|
||
|
||
if (isLoading || !isAuthenticated) {
|
||
return null; // Loading vaqtida yoki auth yo‘q bo‘lsa hech narsa ko‘rmasin
|
||
}
|
||
|
||
return (
|
||
<FilterProvider>
|
||
<SafeAreaView style={{ flex: 1, backgroundColor: isDark ? '#0f172a' : '#ffffff' }}>
|
||
<CustomHeader />
|
||
<HomeScreen />
|
||
</SafeAreaView>
|
||
</FilterProvider>
|
||
);
|
||
}
|