forked from Tima39/ThirdHW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
71 lines (65 loc) · 2.14 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
68
69
70
71
import React, { useState } from 'react';
import { SafeAreaView, View, FlatList, StyleSheet, Text, StatusBar, TouchableOpacity } from 'react-native';
import Profile from './src/screens/Profile';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createStackNavigator } from '@react-navigation/stack';
import Green from './src/screens/Green';
import Red from './src/screens/Red';
import Blue from './src/screens/Blue';
import { createStore } from 'redux';
import { Provider} from 'react-redux';
import reducers from './src/reducers';
import { PersistGate } from 'redux-persist/integration/react';
import { persistStore, persistReducer } from 'redux-persist';
import AsyncStorage from '@react-native-async-storage/async-storage';
//import storage from 'redux-persist/lib/storage';
const persistConfig = {
key: 'user',
storage: AsyncStorage
};
const persistedReducer = persistReducer(persistConfig, reducers)
const store = createStore(persistedReducer);
const persistor = persistStore(store);
const Tab = createBottomTabNavigator();
const Stack = createStackNavigator();
const App = () => {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen name="Home" component={ProfileStack} />
<Tab.Screen name="Settings" component={Green} />
</Tab.Navigator>
</NavigationContainer>
</PersistGate>
</Provider>
);
};
const ProfileStack = () => {
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={Blue} />
<Stack.Screen name="Red" component={Red} />
<Stack.Screen name="Green" component={Green} />
<Stack.Screen name="Profile" component={Profile} />
<Stack.Screen name="Blue" component={Blue} />
</Stack.Navigator>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: StatusBar.currentHeight || 0,
},
item: {
padding: 20,
marginVertical: 8,
marginHorizontal: 16,
},
title: {
fontSize: 32,
},
});
export default App;