-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
53 lines (46 loc) · 1.56 KB
/
App.tsx
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
import 'react-native-gesture-handler';
import React from 'react';
import { StatusBar } from 'react-native';
import { Provider } from 'react-redux';
import { NavigationContainer } from '@react-navigation/native';
import {
createStackNavigator,
StackNavigationOptions,
} from '@react-navigation/stack';
import { useBackHandler } from '@react-native-community/hooks';
import { useResources } from 'app/hooks';
import store from 'app/store';
import { HomeScreen, QuizScreen, ResultScreen } from 'app/components/screens';
import ROUTES, { RootStackParamList } from 'app/config/routes';
import { colors } from 'app/config/theme';
const Stack = createStackNavigator<RootStackParamList>();
const stackOptions: StackNavigationOptions = {
title: null,
headerTransparent: true,
headerTintColor: colors.headerContent,
headerLeft: null,
gestureEnabled: false,
};
const MainStack = () => (
<Stack.Navigator initialRouteName={ROUTES.HOME} screenOptions={stackOptions}>
<Stack.Screen name={ROUTES.HOME} component={HomeScreen} />
<Stack.Screen name={ROUTES.QUIZ} component={QuizScreen} />
<Stack.Screen name={ROUTES.RESULT} component={ResultScreen} />
</Stack.Navigator>
);
export default function App() {
const isLoadingResources = useResources();
// always disable default action of back button
useBackHandler(() => {
return true;
});
if (isLoadingResources) return null;
return (
<Provider store={store}>
<StatusBar barStyle="dark-content" />
<NavigationContainer>
<MainStack />
</NavigationContainer>
</Provider>
);
}