-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
161 lines (140 loc) · 3.73 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import React, {Component, useEffect} from 'react';
import { View, Text } from "react-native";
import RNBootSplash from "react-native-bootsplash";
import SideBar from './Partials/SideBar';
import LoginComponent from './Components/LoginComponent';
import Screen from './Components/Screen';
import Screen2 from './Components/Screen2';
import {StyleProvider, Root, Button} from 'native-base';
import getTheme from './native-base-theme/components';
import material from './native-base-theme/variables/material';
//Redux dependencies
import {Provider} from 'react-redux';
import {createStore, combineReducers, applyMiddleware} from 'redux';
import thunk from 'redux-thunk';
import {userDataReducer} from './Redux/Reducers/Reducer';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
const store = createStore(
combineReducers({
userdata: userDataReducer,
}),
applyMiddleware(thunk),
);
/*
const Screen_StackNavigator = createStackNavigator({
Home: {
screen: Screen,
navigationOptions: ({navigation}) => ({
title: 'Screen 1',
headerTitleStyle: {
marginLeft: 10,
},
headerStyle: {
backgroundColor: '#009FDA',
},
headerTintColor: '#fff',
}),
},
});
const Screen2_StackNavigator = createStackNavigator({
Screen2: {
screen: Screen2,
navigationOptions: ({navigation}) => ({
title: 'Screen 2',
headerTitleStyle: {
marginLeft: 10,
},
headerStyle: {
backgroundColor: '#009FDA',
},
headerTintColor: '#fff',
}),
},
});
const HomeDrawerNavigator = createDrawerNavigator(
{
Home: {
screen: Screen_StackNavigator,
},
Screen2: {
screen: Screen2_StackNavigator,
},
},
{
initialRouteName: 'Home',
contentComponent: props => <SideBar {...props} />,
},
);
const AppContainer = createAppContainer(HomeDrawerNavigator);
class App extends Component {
constructor(props) {
super(props);
//this.state = {}
}
componentDidMount() {
RNBootSplash.hide({duration: 1000});
}
render() {
return (
<StyleProvider style={getTheme(material)}>
<Root>
<Provider store={store}>
<AppContainer
ref={nav => {
this.navigator = nav;
}}
/>
</Provider>
</Root>
</StyleProvider>
);
}
}
export default App;
*/
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button
onPress={() => navigation.navigate('Notifications')}
title="Go to notifications"
/>
</View>
);
}
function NotificationsScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button onPress={() => navigation.goBack()} title="Go back home" />
</View>
);
}
const Drawer = createDrawerNavigator();
function App() {
useEffect(() => {
const init = async () => {
// …do multiple sync or async tasks
};
init().finally(async () => {
await RNBootSplash.hide({ fade: true });
console.log("Bootsplash has been hidden successfully");
});
}, []);
return (
<StyleProvider style={getTheme(material)}>
<Root>
<Provider store={store}>
<NavigationContainer>
<Drawer.Navigator initialRouteName="Login">
<Drawer.Screen name="Login" component={LoginComponent} />
<Drawer.Screen name="Home" component={Screen} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
</Provider>
</Root>
</StyleProvider>
);
}
export default App