-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
79 lines (57 loc) · 1.79 KB
/
App.js
File metadata and controls
79 lines (57 loc) · 1.79 KB
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
import React,{Component} from 'react'
import {I18nManager,YellowBox ,AppState} from 'react-native'
import {UserApp, MainApp} from './src/index'
import personClassService from './src/services/personService'
import workGroupClassService from './src/services/workGroupService'
import AccountService from './src/services/AccountService'
import NetInfo from '@react-native-community/netinfo'
import SplashScreen from './src/shared/splash'
import Login from './src/Account/login'
import AsyncStorage from '@react-native-community/async-storage/lib';
export default class App extends React.Component
{
accountService;
constructor(props)
{
super(props);
YellowBox.ignoreWarnings(['ViewPagerAndroid','ListView','NetInfo']);
if(!I18nManager.isRTL)
{
I18nManager.forceRTL(true)
}
this.accountService=new AccountService();
this.accountService.successLogin=()=>{
this.setState({isLogin:true});
};
this.accountService.successLogOut=()=>{
AsyncStorage.clear();
this.setState({isLogin:false});
};
this.state={
isConnected:true,
isSplash:true,
isLogin:false
}
setTimeout(()=>{
this.setState({isSplash:false});
},1500);
NetInfo.addEventListener((netState)=>{
this.setState({isConnected:netState.isConnected});
});
}
render()
{
if(this.state.isSplash)
return (<SplashScreen />)
if(!this.state.isLogin)
return (<Login accountService={this.accountService}/>);
let screens={
options:{isConnected:this.state.isConnected},accountService:this.accountService,
personService:new personClassService(),workGroupService:new workGroupClassService()};
if(!this.accountService.isAdmin)
{
return (<UserApp screenProps={screens}/>)
}
return (<MainApp screenProps={screens}/>)
}
}