forked from quarck/CalendarNotification
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.tsx
More file actions
149 lines (138 loc) · 5.01 KB
/
index.tsx
File metadata and controls
149 lines (138 loc) · 5.01 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
138
139
140
141
142
143
144
145
146
147
148
149
// Entry point for React Native
import 'react-native-devsettings';
import './global.css';
import './src/lib/env';
import React from 'react';
import { AppRegistry, Text } from 'react-native';
import { NavigationContainer, DefaultTheme, DarkTheme } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { enableScreens } from 'react-native-screens';
// Enable native screens for performance
enableScreens();
import { TouchableOpacity, BackHandler } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { PowerSyncContext } from '@powersync/react';
import { db as psDb } from './src/lib/powersync';
import { setupPowerSyncLogCapture } from './src/lib/powersync/Connector';
import { SettingsProvider } from './src/lib/hooks/SettingsContext';
import { SyncDebugProvider } from './src/lib/hooks/SyncDebugContext';
import { ThemeProvider, useTheme } from './src/lib/theme/ThemeContext';
import { GluestackUIProvider } from './src/components/ui/gluestack-ui-provider';
import Logger from 'js-logger';
// Screens
import HomeScreen from './src/screens/index';
import SettingsScreen from './src/screens/settings';
import SyncDebugScreen from './src/screens/sync-debug';
// Initialize logger
Logger.useDefaults();
Logger.setLevel(Logger.DEBUG);
setupPowerSyncLogCapture();
const Stack = createNativeStackNavigator();
function BackButton({ onPress, color, hasRightHeader }: { onPress: () => void; color: string; hasRightHeader?: boolean }) {
return (
<TouchableOpacity
onPress={onPress}
hitSlop={{ top: 15, bottom: 15, left: 15, right: 15 }}
style={{ padding: 8, marginLeft: hasRightHeader ? 8 : 0 }}
>
<Ionicons name="arrow-back" size={24} color={color} />
</TouchableOpacity>
);
}
/**
* Main app content - uses useTheme() to get colors from ThemeProvider.
* This must be rendered inside ThemeProvider.
*/
function AppContent() {
const { isDark, colors } = useTheme();
// Custom navigation theme
const navigationTheme = isDark ? {
...DarkTheme,
colors: {
...DarkTheme.colors,
primary: colors.primary,
background: colors.background,
card: colors.backgroundWhite,
text: colors.text,
border: colors.border,
},
} : {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: colors.primary,
background: colors.background,
card: colors.backgroundWhite,
text: colors.text,
border: colors.border,
},
};
return (
<GluestackUIProvider mode={isDark ? 'dark' : 'light'}>
<SettingsProvider>
<SyncDebugProvider>
<PowerSyncContext.Provider value={psDb}>
<NavigationContainer theme={navigationTheme}>
<Stack.Navigator
screenOptions={{
headerStyle: { backgroundColor: colors.backgroundWhite },
headerTintColor: colors.primary,
headerTitleStyle: { color: colors.text },
headerBackVisible: false,
}}
>
<Stack.Screen
name="Home"
component={HomeScreen}
options={({ navigation }) => ({
title: 'Sync Info',
headerLeft: () => (
<BackButton onPress={() => BackHandler.exitApp()} color={colors.primary} hasRightHeader />
),
headerRight: () => (
<TouchableOpacity
onPress={() => navigation.navigate('Settings')}
hitSlop={{ top: 15, bottom: 15, left: 15, right: 15 }}
style={{ padding: 8, marginRight: 4 }}
>
<Text style={{ fontSize: 24, color: colors.primary }}>⋮</Text>
</TouchableOpacity>
),
})}
/>
<Stack.Screen
name="Settings"
component={SettingsScreen}
options={({ navigation }) => ({
title: 'Sync Settings',
headerLeft: () => (
<BackButton onPress={() => navigation.goBack()} color={colors.primary} />
),
})}
/>
<Stack.Screen
name="SyncDebug"
component={SyncDebugScreen}
options={({ navigation }) => ({
title: 'Sync Debug',
headerLeft: () => (
<BackButton onPress={() => navigation.goBack()} color={colors.primary} />
),
})}
/>
</Stack.Navigator>
</NavigationContainer>
</PowerSyncContext.Provider>
</SyncDebugProvider>
</SettingsProvider>
</GluestackUIProvider>
);
}
function App() {
return (
<ThemeProvider>
<AppContent />
</ThemeProvider>
);
}
AppRegistry.registerComponent('CNPlusSync', () => App);