-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
91 lines (80 loc) · 2.78 KB
/
App.tsx
File metadata and controls
91 lines (80 loc) · 2.78 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
/**
* Todo App - Cross-platform Task Management
*
* @format
*/
import React, { useEffect } from 'react';
import { Provider } from 'react-redux';
import { StyleSheet } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { store } from './src/store';
import { ThemeProvider } from './src/theme/ThemeContext';
import { RootNavigator } from './src/navigation/RootNavigator';
import { realmService } from './src/services/database/realmService';
import { notificationService } from './src/services/notifications/notificationService';
import { syncService } from './src/services/sync/syncService';
import ThemedStatusBar from './src/components/ThemedStatusBar';
import { OfflineBanner } from './src/components/OfflineBanner';
import { NetworkProvider } from './src/components/NetworkProvider';
function App(): React.JSX.Element {
useEffect(() => {
// Initialize services
const initializeApp = async () => {
try {
console.log('🚀 Initializing app...');
await realmService.init();
console.log('✅ Realm initialized');
await notificationService.initialize();
console.log('✅ Notification service initialized');
// Initialize sync service
syncService.initialize();
console.log('✅ Sync service initialized');
// Reschedule notifications for tasks with future reminders
const allTasks = await realmService.getAllTasks('');
const tasksWithReminders = allTasks
.filter(task => task.reminderTime && task.reminderTime > Date.now())
.map(task => ({
id: task.id,
title: task.title,
reminderTime: task.reminderTime,
}));
if (tasksWithReminders.length > 0) {
await notificationService.rescheduleNotifications(tasksWithReminders);
}
console.log('✅ App initialization complete');
} catch (error) {
console.error('❌ Failed to initialize app:', error);
if (error instanceof Error) {
console.error('Error details:', error.message, error.stack);
}
}
};
initializeApp();
return () => {
realmService.close();
syncService.cleanup();
};
}, []);
return (
<Provider store={store}>
<NetworkProvider>
<SafeAreaProvider>
<GestureHandlerRootView style={styles.container}>
<ThemeProvider>
<ThemedStatusBar />
<OfflineBanner />
<RootNavigator />
</ThemeProvider>
</GestureHandlerRootView>
</SafeAreaProvider>
</NetworkProvider>
</Provider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default App;