ueberpruefen
This commit is contained in:
86
App.tsx
86
App.tsx
@@ -1,20 +1,94 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
import { View, Text, StyleSheet, ActivityIndicator } from 'react-native';
|
||||
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
||||
import 'react-native-gesture-handler';
|
||||
import { AppNavigator } from './src/navigation';
|
||||
import { AuthProvider } from './src/contexts/AuthContext';
|
||||
import { openDatabase } from './src/lib/db';
|
||||
import { seedGlazeCatalog } from './src/lib/db/repositories';
|
||||
import { analytics } from './src/lib/analytics';
|
||||
import { colors } from './src/lib/theme';
|
||||
|
||||
export default function App() {
|
||||
const [isReady, setIsReady] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
initializeApp();
|
||||
}, []);
|
||||
|
||||
const initializeApp = async () => {
|
||||
try {
|
||||
// Initialize database
|
||||
await openDatabase();
|
||||
|
||||
// Seed glaze catalog if not already seeded
|
||||
await seedGlazeCatalog();
|
||||
|
||||
// Initialize analytics
|
||||
await analytics.initialize();
|
||||
|
||||
// Track app open
|
||||
analytics.appOpen(true);
|
||||
|
||||
setIsReady(true);
|
||||
} catch (err) {
|
||||
console.error('Failed to initialize app:', err);
|
||||
setError(err instanceof Error ? err.message : 'Unknown error');
|
||||
}
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.errorText}>Failed to initialize app</Text>
|
||||
<Text style={styles.errorDetail}>{error}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (!isReady) {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<ActivityIndicator size="large" color={colors.primary} />
|
||||
<Text style={styles.loadingText}>Loading...</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>Open up App.tsx to start working on your app!</Text>
|
||||
<StatusBar style="auto" />
|
||||
</View>
|
||||
<SafeAreaProvider>
|
||||
<AuthProvider>
|
||||
<AppNavigator />
|
||||
<StatusBar style="auto" />
|
||||
</AuthProvider>
|
||||
</SafeAreaProvider>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
backgroundColor: '#fff',
|
||||
backgroundColor: colors.background,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
loadingText: {
|
||||
marginTop: 16,
|
||||
fontSize: 16,
|
||||
color: colors.textSecondary,
|
||||
},
|
||||
errorText: {
|
||||
fontSize: 18,
|
||||
fontWeight: '600',
|
||||
color: colors.error,
|
||||
marginBottom: 8,
|
||||
},
|
||||
errorDetail: {
|
||||
fontSize: 14,
|
||||
color: colors.textSecondary,
|
||||
textAlign: 'center',
|
||||
paddingHorizontal: 32,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user