-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
138 lines (125 loc) · 4.48 KB
/
App.js
File metadata and controls
138 lines (125 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import React, { useState, useEffect } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { Provider as PaperProvider } from 'react-native-paper';
import { StatusBar } from 'expo-status-bar';
// Import screens
import HomeScreen from './src/screens/HomeScreen';
import SimpleTripScreen from './src/screens/SimpleTripScreen';
import AnalysisScreen from './src/screens/AnalysisScreen';
import ResultsScreen from './src/screens/ResultsScreen';
import NarrativeScreen from './src/screens/NarrativeScreen';
import DashboardScreen from './src/screens/DashboardScreen';
import TripDetailsScreen from './src/screens/TripDetailsScreen';
import PromptResultsScreen from './src/screens/PromptResultsScreen';
// Import context and error boundary
import { AppProvider } from './src/context/AppContext';
import { ThemeProvider } from './src/context/ThemeContext';
import ErrorBoundary from './src/components/ErrorBoundary';
import ApiService from './src/services/ApiService';
import { Colors } from './src/constants/Colors';
import { testColorSystem } from './src/utils/ColorSystemTest';
const Stack = createStackNavigator();
function App() {
const [selectedMedia, setSelectedMedia] = useState([]);
const [analysisResults, setAnalysisResults] = useState(null);
const [isAnalyzing, setIsAnalyzing] = useState(false);
// Global error handler for unhandled errors
useEffect(() => {
// Override console.error to catch Jimp errors
const originalConsoleError = console.error;
console.error = (...args) => {
const errorMessage = args.join(' ');
if (errorMessage.includes('Could not find MIME for Buffer')) {
console.warn('Jimp MIME error detected:', errorMessage);
return; // Don't log as error
}
originalConsoleError.apply(console, args);
};
// Test API key on app start
const testAPIKey = async () => {
console.log('🧪 [APP] Testing API keys on startup...');
await ApiService.testVisionAPIKey();
};
// Test color system on app start
const testColors = () => {
console.log('🎨 [APP] Testing color system on startup...');
testColorSystem();
};
testAPIKey();
testColors();
return () => {
console.error = originalConsoleError;
};
}, []);
const contextValue = {
selectedMedia,
setSelectedMedia,
analysisResults,
setAnalysisResults,
isAnalyzing,
setIsAnalyzing,
};
return (
<ErrorBoundary>
<ThemeProvider>
<PaperProvider>
<AppProvider value={contextValue}>
<NavigationContainer>
<StatusBar style="auto" />
<Stack.Navigator
initialRouteName="Dashboard"
screenOptions={{
headerStyle: {
backgroundColor: Colors.primary.main,
},
headerTintColor: Colors.primary.contrast,
headerTitleStyle: {
fontWeight: 'bold',
},
}}
>
<Stack.Screen
name="Dashboard"
component={DashboardScreen}
options={{ title: 'My Trips' }}
/>
<Stack.Screen
name="TripDetails"
component={TripDetailsScreen}
options={{ title: 'Trip Details' }}
/>
<Stack.Screen
name="SimpleTrip"
component={SimpleTripScreen}
options={{ title: 'Select Trip Dates' }}
/>
<Stack.Screen
name="Analysis"
component={AnalysisScreen}
options={{ title: 'Analyzing Media...' }}
/>
<Stack.Screen
name="Results"
component={ResultsScreen}
options={{ title: 'Analysis Results' }}
/>
<Stack.Screen
name="Narrative"
component={NarrativeScreen}
options={{ title: 'Trip Narrative' }}
/>
<Stack.Screen
name="PromptResults"
component={PromptResultsScreen}
options={{ title: 'Generated Posts' }}
/>
</Stack.Navigator>
</NavigationContainer>
</AppProvider>
</PaperProvider>
</ThemeProvider>
</ErrorBoundary>
);
}
export default App;