-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
72 lines (64 loc) · 2.22 KB
/
Copy pathApp.tsx
File metadata and controls
72 lines (64 loc) · 2.22 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
import React, {useEffect} from 'react';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import {StatusBar} from 'react-native';
import notifee from '@notifee/react-native';
import {ThemeProvider} from './src/app/providers/ThemeProvider';
import {I18nProvider} from './src/app/providers/I18nProvider';
import {RootNavigator} from './src/navigation/RootNavigator';
import {useTheme} from './src/theme';
import {seedIfEmpty} from './src/store/seed';
import {handleNotifeeEvent} from './src/services/notifications/actionHandlers';
import {GeofenceService} from './src/services/geofence/GeofenceService';
import {useTasksStore} from './src/store/tasksStore';
import {displayArrival} from './src/services/notifications/NotifeeService';
function ThemedStatusBar() {
const theme = useTheme();
return (
<StatusBar
barStyle={theme.mode === 'dark' ? 'light-content' : 'dark-content'}
backgroundColor={theme.colors.bg}
translucent={false}
/>
);
}
function Root() {
useEffect(() => {
// Seed demo data — pure store mutation, no dialogs.
seedIfEmpty();
// Notifee foreground event handler — register immediately so action-button
// presses are handled while the app is open, independent of geofence state.
const unsubNotifee = notifee.onForegroundEvent(handleNotifeeEvent);
// Forward foreground geofence entries to the notification service once
// GeofenceService is running (bootstrapped via SplashScreen after it hides).
const unsubGeofence = GeofenceService.onEnter(id => {
if (!id) return;
const task = useTasksStore.getState().tasks.find(t => t.id === id);
if (!task || task.done) return;
displayArrival(task).catch(() => {});
});
return () => {
unsubNotifee();
unsubGeofence();
};
}, []);
return (
<>
<ThemedStatusBar />
<RootNavigator />
</>
);
}
export default function App() {
return (
<GestureHandlerRootView style={{flex: 1}}>
<SafeAreaProvider>
<I18nProvider>
<ThemeProvider>
<Root />
</ThemeProvider>
</I18nProvider>
</SafeAreaProvider>
</GestureHandlerRootView>
);
}