-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
146 lines (138 loc) · 5.59 KB
/
App.tsx
File metadata and controls
146 lines (138 loc) · 5.59 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator, NativeStackHeaderProps } from '@react-navigation/native-stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import './src/locales/i18n.ts';
import useAuthStore from './src/store/useAuthStore.ts';
import useInitializeApp from './src/hooks/useInitializeApp/index.ts';
import AppWrapper from './src/components/common/AppWrapper/index.tsx';
import CustomHeader from './src/components/common/CustomHeader/index.tsx';
import Toast from 'react-native-toast-message';
import { toastConfig } from './src/components/common/Toast/toast.config.tsx';
import Signup from './src/screens/Signup/index.tsx';
import Signin from './src/screens/Signin';
import Home from './src/screens/Home/index.tsx';
import MyPuzzles from './src/screens/MyPuzzles/index.tsx';
import LikedPuzzles from './src/screens/LikedPuzzles/index.tsx';
import Ranking from './src/screens/Ranking/index.tsx';
import TrainingPacks from './src/screens/TrainingPacks/index.tsx';
import TrainingPuzzles from './src/screens/TrainingPuzzles/index.tsx';
import TrainingPuzzleSolve from './src/screens/TrainingPuzzleSolve/index.tsx';
import CommunityPuzzles from './src/screens/CommunityPuzzles/index.tsx';
import CommunityPuzzleSolve from './src/screens/CommunityPuzzleSolve/index.tsx';
import CreateCommunityPuzzle from './src/screens/CreateCommunityPuzzle/index.tsx';
import RankedPuzzleSolve from './src/screens/RankedPuzzleSolve/index.tsx';
import PuzzleReview from './src/screens/PuzzleReview/index.tsx';
import AnswerCommunityPuzzle from './src/screens/CreateCommunityPuzzle/AnswerCommunityPuzzle/index.tsx';
import { StatusBar } from 'react-native';
import theme from './src/styles/theme.ts';
const Stack = createNativeStackNavigator();
function App(): React.JSX.Element | null {
const { accessToken } = useAuthStore();
const isLoading = useInitializeApp();
const renderCustomHeader = (props: NativeStackHeaderProps) => <CustomHeader {...props} />;
if (isLoading) {
return null;
}
return (
<SafeAreaProvider>
<NavigationContainer>
<AppWrapper>
<StatusBar
barStyle={'dark-content'}
backgroundColor={theme.color['gray/grayBG']}
translucent={false}
/>
<Stack.Navigator
screenOptions={{
header: renderCustomHeader,
}}>
{accessToken ? (
<>
<Stack.Screen name="Home" component={Home} options={{ title: 'common.appName' }} />
<Stack.Screen
name="MyPuzzles"
component={MyPuzzles}
options={{ title: 'common.myPuzzle' }}
/>
<Stack.Screen
name="LikedPuzzles"
component={LikedPuzzles}
options={{ title: 'common.likes' }}
/>
<Stack.Screen
name="Ranking"
component={Ranking}
options={{ title: 'common.ranking' }}
/>
<Stack.Screen
name="TrainingPacks"
component={TrainingPacks}
options={{ title: 'home.trainingPuzzle' }}
/>
<Stack.Screen
name="TrainingPuzzles"
component={TrainingPuzzles}
options={{ title: 'home.trainingPuzzle' }}
/>
<Stack.Screen
name="TrainingPuzzleSolve"
component={TrainingPuzzleSolve}
options={{ title: 'home.trainingPuzzle' }}
/>
<Stack.Screen
name="TrainingPuzzleReview"
component={PuzzleReview}
options={{ title: 'home.trainingPuzzle' }}
/>
<Stack.Screen
name="CommunityPuzzles"
component={CommunityPuzzles}
options={{ title: 'home.communityPuzzle' }}
/>
<Stack.Screen
name="CommunityPuzzleSolve"
component={CommunityPuzzleSolve}
options={{ title: 'home.communityPuzzle' }}
/>
<Stack.Screen
name="CommunityPuzzleReview"
component={PuzzleReview}
options={{ title: 'home.communityPuzzle' }}
/>
<Stack.Screen
name="CreateCommunityPuzzle"
component={CreateCommunityPuzzle}
options={{ title: 'home.communityPuzzle' }}
/>
<Stack.Screen
name="AnswerCommunityPuzzle"
component={AnswerCommunityPuzzle}
options={{ title: 'home.communityPuzzle' }}
/>
<Stack.Screen
name="RankedPuzzleSolve"
component={RankedPuzzleSolve}
options={{ title: 'home.rankingPuzzle' }}
/>
</>
) : (
<>
<Stack.Screen name="Signin" component={Signin} options={{ headerShown: false }} />
<Stack.Screen name="Signup" component={Signup} options={{ title: 'auth.signup' }} />
</>
)}
</Stack.Navigator>
</AppWrapper>
<Toast config={toastConfig} />
</NavigationContainer>
</SafeAreaProvider>
);
}
export default App;