-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
73 lines (64 loc) · 2.26 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
import React, {Component} from 'react';
import 'react-native-gesture-handler';
import {createStackNavigator} from '@react-navigation/stack';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {NavigationContainer} from '@react-navigation/native';
import SplashScreen from './src/screen/SplashScreen';
import WelcomeScreen from './src/screen/WelcomeScreen';
import HomeScreen from './src/screen/HomeScreen';
import CustomSidebarMenu from './src/navigation/CustomSidebarMenu';
import AsyncStorage from '@react-native-community/async-storage';
import messaging from '@react-native-firebase/messaging';
import firebase from '@react-native-firebase/app';
const MainStack = createStackNavigator();
const RootStack = createStackNavigator();
const ProductStack = createStackNavigator();
const OrderStack = createStackNavigator();
const Drawer = createDrawerNavigator();
global.currentScreenIndex = 0;
class App extends Component {
constructor(props) {
super(props);
this.state = {};
}
createDrawer = () => (
<Drawer.Navigator
initialRouteName="Home"
drawerContent={props => <CustomSidebarMenu {...props} />}>
<Drawer.Screen name="Home" component={HomeScreen} />
</Drawer.Navigator>
);
MainStackScreen = () => (
<MainStack.Navigator
screenOptions={{
headerShown: false,
animationEnabled: false,
}}>
<MainStack.Screen name="SplashScreen" component={SplashScreen} />
<MainStack.Screen name="WelcomeScreen" component={WelcomeScreen} />
</MainStack.Navigator>
);
RootStackScreen = () => (
<RootStack.Navigator
screenOptions={{
headerShown: false,
animationEnabled: false,
}}>
<RootStack.Screen name="Main" component={this.MainStackScreen} />
<RootStack.Screen name="Home" children={this.createDrawer} />
</RootStack.Navigator>
);
componentDidMount = async () => {
this.createNotificationListeners();
};
async createNotificationListeners() {
const unsubscribe = messaging().onMessage(async remoteMessage => {
Alert.alert('A new FCM message arrived!', JSON.stringify(remoteMessage));
});
return unsubscribe;
}
render() {
return <NavigationContainer>{this.RootStackScreen()}</NavigationContainer>;
}
}
export default App;