-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
67 lines (59 loc) · 2.16 KB
/
App.js
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
import { SafeAreaProvider } from 'react-native-safe-area-context';
import SafeAreaView from 'react-native-safe-area-view';
import {
NavigationContainer,
} from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { TabNavigationScreens, Reason } from './screens';
import { PersistGate } from 'redux-persist/integration/react';
import { Provider as ReduxProvider, useDispatch } from 'react-redux';
import { StyleSheet } from 'react-native';
import { Provider as PaperProvider } from 'react-native-paper';
import { createContext } from 'react';
import { useTheme } from './hooks';
import configureStorage from './redux/configureStorage';
import { toggleTheme } from './redux/actions';
import 'intl'; // to solve 'cant find variable Intl' error in react native paper dates
import 'intl/locale-data/jsonp/en'; // this line is also required; that's all i know.
const { store, persistor } = configureStorage();
const Stack = createNativeStackNavigator();
export const ToggleTheme = createContext();
const ThemedApp = () => {
const theme = useTheme();
const dispatch = useDispatch();
return (
<PaperProvider theme={theme}>
<ToggleTheme.Provider value={{ toggleTheme: function(){
dispatch(toggleTheme())
} }}>
<NavigationContainer theme={theme}>
<Stack.Navigator
initialRouteName='TabNavigationScreens'
screenOptions={{ headerShown: false }}>
<Stack.Screen
name='TabNavigationScreens'
component={TabNavigationScreens}
/>
<Stack.Screen name='Reason' component={Reason} />
</Stack.Navigator>
</NavigationContainer>
</ToggleTheme.Provider>
</PaperProvider>
);
};
export default function App() {
return (
<SafeAreaProvider>
<SafeAreaView forceInset={{ top: 'always' }} style={{ flex: 1 }}>
<ReduxProvider store={store}>
<PersistGate loading={null} persistor={persistor}>
<ThemedApp />
</PersistGate>
</ReduxProvider>
</SafeAreaView>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
container: {},
});