-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
173 lines (157 loc) · 4.34 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
162
163
164
165
166
167
168
169
170
171
172
173
import 'react-native-gesture-handler';
import React, {Component, useState, useEffect} from 'react';
import {
BackHandler,
StyleSheet,
Text,
View,
Button,
TouchableOpacity,
Dimensions,
AsyncStorage,
Image,
Animated,
} from 'react-native';
import {COLOR, ThemeContext, getTheme} from 'react-native-material-ui';
import {Provider} from 'react-redux';
import {createStore, applyMiddleware, compose} from 'redux';
import Reducer from './Store/reducer';
import KeyboardShift from './Components/utils/keyboardShift';
import {StatusBar} from 'react-native';
import {TouchableWithoutFeedback} from 'react-native-gesture-handler';
import AuthRoutes from './Container/authRoutes';
import BuyerRoutes from './Container/buyerRoutes';
import SellerRoutes from './Container/sellerRoutes';
const uiTheme = {
palette: {
primaryColor: COLOR.blue500,
},
toolbar: {
container: {
height: 50,
},
},
};
class App extends Component {
constructor(props) {
super(props);
this.state = {
animation : new Animated.Value(1),
isLoggedIn: false,
isSignedIn: false,
isSellerSignedIn:false,
userType: null,
isVisible: true,
width: Dimensions.get('window').width,
accessToken: null,
};
}
startAnimation=()=>{
Animated.timing(this.state.animation, {
toValue : 1,
timing : 3000
}).start(()=>{
Animated.timing(this.state.animation,{
toValue : 0,
duration :1000
}).start();
})
}
Hide_Splash_Screen = () => {
this.setState({
isVisible: false,
});
};
async componentDidMount() {
this.startAnimation();
const isLoggedIn = await AsyncStorage.getItem('isLoggedIn');
const user = await AsyncStorage.getItem('userType');
if (isLoggedIn) {
this.setState({isLoggedIn: true, userType: user});
}
var that = this;
setTimeout(function() {
that.Hide_Splash_Screen();
}, 4000);
}
onLogoutSession = () => {
this.setState({isLoggedIn: false});
this.setState({isSignedIn: false});
this.setState({userType:null})
};
onsignIn = async () => {
this.setState({isSignedIn: true,isSellerSignedIn:false});
};
onsellersignIn = async () => {
this.setState({isSignedIn:true,isSellerSignedIn:true});
};
render() {
const animatedStyle ={
opacity : this.state.animation,
}
const styles = StyleSheet.create({
headerRightContainerStyle: {
width: this.state.width - 20,
alignItems: 'center',
},
MainContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
paddingTop: Platform.OS === 'ios' ? 20 : 0,
},
SplashScreen_RootView: {
justifyContent: 'center',
flex: 1,
position: 'absolute',
width: '100%',
height: '100%',
},
SplashScreen_ChildView: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#efebea',
flex: 1,
},
});
const store = createStore(Reducer);
let Splash_Screen = (
<Animated.View style={[styles.SplashScreen_RootView,animatedStyle]}>
<View style={styles.SplashScreen_ChildView}>
<Image
source={require('./assets/Images/logos/Logo_Microffee.png')}
style={{width: '100%', height: '100%', resizeMode: 'contain'}}
/>
</View>
</Animated.View>
);
return (
<ThemeContext.Provider value={getTheme(uiTheme)}>
<Provider store={store}>
<StatusBar
barStyle="dark-content"
hidden={false}
backgroundColor="#7ea100"
translucent={true}
barStyle="light-content"
/>
{this.state.isLoggedIn || this.state.isSignedIn ? (
this.state.isSellerSignedIn || this.state.userType === 'Seller' ? (
<SellerRoutes onLogoutSession={this.onLogoutSession} />
) : (
<BuyerRoutes onLogoutSession={this.onLogoutSession} />
)
) : (
<AuthRoutes
{...this.state}
onSignedIn={this.onsignIn}
onSellerSignedIn={this.onsellersignIn}
/>
)}
</Provider>
{this.state.isVisible === true ? Splash_Screen : null}
</ThemeContext.Provider>
);
}
}
export default App;