-
Notifications
You must be signed in to change notification settings - Fork 6
/
AppRoot.js
104 lines (97 loc) · 2.72 KB
/
AppRoot.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
import React from 'react';
import { StyleSheet, View, Modal } from 'react-native';
import { StackNavigator } from 'react-navigation';
import Toaster from 'react-native-toaster';
import * as launchImage from 'react-native-launch-image';
import Loading from './common/components/Loading';
import Login from "./scene/Login";
import Confirm from "./scene/Confirm";
import About from './scene/About';
import OpenSource from "./scene/OpenSource";
import Office from "./scene/Office";
import WebView from "./scene/WebView";
import TabNavigator from "./Main";
import { inject, observer } from 'mobx-react/native';
const App = StackNavigator(
{
Main: {
screen: TabNavigator,
navigationOptions: {
gesturesEnabled: false,
},
},
Login: {
screen: Login,
navigationOptions: {
headerLeft: null,
gesturesEnabled: false,
},
},
Confirm: {
screen: Confirm,
},
About: {
screen: About,
},
OpenSource: {
screen: OpenSource,
},
Office: {
screen: Office
},
WebView: {
screen: WebView,
}
},
{
mode: 'card',
}
);
@inject('rootStore')
@observer
export default class AppRoot extends React.Component {
async componentWillMount() {
launchImage.hide();
// await this.props.rootStore.StorageStore.constructor.remove('user');
// await this.props.rootStore.StorageStore.constructor.remove('course');
// await this.props.rootStore.StorageStore.constructor.remove('exam');
// await this.props.rootStore.StorageStore.constructor.remove('grade');
// await this.props.rootStore.StorageStore.constructor.remove('gpa');
// await this.props.rootStore.StorageStore.constructor.remove('allGrade');
// await this.props.rootStore.StorageStore.constructor.remove('xifu');
try {
const lastLoginData = await this.props.rootStore.StorageStore.constructor.load('xifu');
if (lastLoginData.username.length === 11) {
await this.props.rootStore.xiFuStore.setBind(true, lastLoginData.username);
}
} catch (err) {
return false;
}
}
render() {
const userStoreData = this.props.rootStore.UserStore.allData;
const loadingData = this.props.rootStore.LoadingStore.allData;
return (
<View style={styles.screen}>
<Toaster
message={userStoreData.toastMessage}
/>
<Modal
animationType={"fade"}
transparent={true}
visible={loadingData.loadingVisible}
>
<Loading text={loadingData.loadingText}/>
</Modal>
<App />
</View>
)
}
}
const $backgroundColor = 'rgb(239, 239, 244)';
const styles = StyleSheet.create({
screen: {
flex: 1,
backgroundColor: $backgroundColor
}
});