-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
73 lines (66 loc) · 2.79 KB
/
Copy pathApp.tsx
File metadata and controls
73 lines (66 loc) · 2.79 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
import React, { useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { useStore } from '@/store';
import { ErrorBoundary } from '@/components/ErrorBoundary';
import { MainTabs } from '@/navigation/MainTabs';
import { ModeEditorScreen } from '@/screens/ModeEditorScreen';
import { ModeDetailScreen } from '@/screens/ModeDetailScreen';
import { PairCubeScreen } from '@/screens/PairCubeScreen';
import { ScanScreen } from '@/screens/ScanScreen';
import { BlockPreviewScreen } from '@/screens/BlockPreviewScreen';
import type { RootStackParamList } from '@/types';
const Stack = createNativeStackNavigator<RootStackParamList>();
function withBoundary<P extends object>(Comp: React.ComponentType<P>) {
return function Wrapped(props: P) {
return (
<ErrorBoundary>
<Comp {...props} />
</ErrorBoundary>
);
};
}
const Tabs = withBoundary(MainTabs);
const ModeEditor = withBoundary(ModeEditorScreen);
const ModeDetail = withBoundary(ModeDetailScreen);
const PairCube = withBoundary(PairCubeScreen);
const Scan = withBoundary(ScanScreen);
const BlockPreview = withBoundary(BlockPreviewScreen);
export default function App() {
const hydrate = useStore((s) => s.hydrate);
const pairedCube = useStore((s) => s.pairedCube);
useEffect(() => {
hydrate();
}, [hydrate]);
return (
<SafeAreaProvider>
<ErrorBoundary>
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerStyle: { backgroundColor: '#0F0F12' },
headerTitleStyle: { color: '#FFFFFF', fontWeight: '600' },
headerTintColor: '#FFFFFF',
contentStyle: { backgroundColor: '#0F0F12' },
}}
initialRouteName={pairedCube ? 'MainTabs' : 'PairCube'}
>
<Stack.Screen name="MainTabs" component={Tabs} options={{ headerShown: false }} />
<Stack.Screen name="ModeEditor" component={ModeEditor} options={{ title: 'Mode' }} />
<Stack.Screen name="ModeDetail" component={ModeDetail} options={{ title: 'Mode' }} />
<Stack.Screen name="PairCube" component={PairCube} options={{ title: 'Pair your cube' }} />
<Stack.Screen name="Scan" component={Scan} options={{ title: 'Scan cube', presentation: 'modal' }} />
<Stack.Screen
name="BlockPreview"
component={BlockPreview}
options={{ headerShown: false, presentation: 'fullScreenModal' }}
/>
</Stack.Navigator>
</NavigationContainer>
</ErrorBoundary>
<StatusBar style="light" />
</SafeAreaProvider>
);
}