-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
151 lines (141 loc) · 4.3 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
import { createDrawerNavigator } from '@react-navigation/drawer';
import { DefaultTheme, NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import React, { useEffect } from 'react';
import { ActivityIndicator, LogBox, Modal, View } from 'react-native';
import RNBootSplash from "react-native-bootsplash";
import { enableLatestRenderer } from 'react-native-maps';
import Toast, { BaseToast } from 'react-native-toast-message';
import { connect } from 'react-redux';
import OrderDetail from './Src/Screens/Product/OrderDetail';
import ProductDetail from './Src/Screens/Product/ProductDetail';
import RightDrawer from './Src/Screens/RightDrawer';
import Dashboard from './Src/Screens/User/Dashboard';
import Login from './Src/Screens/User/Login';
import Signup from './Src/Screens/User/Signup';
import DepositRequests from './Src/Screens/Wallet/DepositRequests';
import {
ChangeNavigation
} from './Src/Store/Actions/sharedActions';
import {
ChangeUserData, GetUserData
} from './Src/Store/Actions/userActions';
LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message
LogBox.ignoreAllLogs();//Ignore all log notifications
LogBox.ignoreLogs(['Animated: `useNativeDriver`']);
const DrawerNavigator = createDrawerNavigator()
const Stack = createStackNavigator()
function App(props) {
const { textOffColor,
warningColor,
dangerColor,
successLightColor,
successColor,
modalBorderColor,
modalColor,
textColor,
backgroundColor,
backgroundDarkerColor,
mainDarkerColor,
mainLighterColor,
mainColor,
} = props.color
const {
loader,
} = props.shared
const {
userData
} = props.user
const {
ChangeNavigation,
ChangeUserData,
} = props
const MyTheme = {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
primary: mainColor,
background: backgroundColor,
card: modalColor,
text: textColor,
border: modalColor,
notification: mainLighterColor,
},
}
const toastConfig = {
success: ({ text1, text2, ...rest }) => (
<BaseToast
{...rest}
style={{ borderLeftColor: mainLighterColor }}
contentContainerStyle={{ paddingHorizontal: 15 }}
text1Style={{
fontSize: 15,
fontWeight: 'bold'
}}
text2Style={{
fontSize: 12,
}}
text1={text1}
text2={text2}
/>
)
}
useEffect(() => {
RNBootSplash.hide({ fade: true }); // fade
enableLatestRenderer();
GetUserData().then((data) => {
console.log("DATA")
console.log(data)
if (data == null) {
console.log("DATA IS NULL")
ChangeUserData('')
} else {
ChangeUserData(data)
}
})
}, [])
return (
<>
<NavigationContainer theme={MyTheme}>
{userData == null || userData == '' ?
<Stack.Navigator
headerMode="none"
initialRouteName="Login" // change to Login
mode="modal"
>
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="Signup" component={Signup} />
</Stack.Navigator>
:
<Stack.Navigator
headerMode="none"
initialRouteName="RightDrawer" // change to RightDrawer
mode="modal"
>
<Stack.Screen name="RightDrawer" component={RightDrawer} />
<Stack.Screen name="DepositRequests" component={DepositRequests} />
<Stack.Screen name="ProductDetail" component={ProductDetail} />
<Stack.Screen name="OrderDetail" component={OrderDetail} />
<Stack.Screen name="Dashboard" component={Dashboard} />
</Stack.Navigator>
}
</NavigationContainer>
<Toast config={toastConfig} ref={(ref) => Toast.setRef(ref)} />
<Modal
visible={loader}
transparent={true}
>
<View style={{ backgroundColor: "#000000aa", flex: 1, justifyContent: "center", paddingLeft: '3%', paddingRight: '3%' }}>
<ActivityIndicator size="large" color={mainLighterColor} />
</View>
</Modal>
</>
)
}
const mapStateToProps = ({ color, shared, user }) => ({
color, shared, user
})
export default connect(mapStateToProps, {
ChangeNavigation,
ChangeUserData,
})(App)