index.js
5.13 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
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
174
/**
* Created by Cassie on 208/03/21.
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
NativeModules,
AsyncStorage,
Platform
} from 'react-native';
import {StackNavigator,TabNavigator,NavigationActions} from 'react-navigation';
import SplashScreen from "rn-splash-screen";
import {getHeaderHeight,getHeaderPadding,getFooterBottom} from "./utils/utils";
import SignIn from "./pages/login/signIn";
import Register from "./pages/login/register";
import ForgetPwd from "./pages/login/forgetPwd";
import SafeEscort from "./pages/root/safeEscort";
import EventReport from "./pages/root/eventReport";
import Home from "./pages/root/home";
import Volunteer from "./pages/root/volunteer"
import Community from "./pages/root/community";
import PersonCenter from "./pages/personCenter/index";
import Info from "./pages/personCenter/Info";
import MyEvents from './pages/homeClick/myEvents';
import myMessage from './pages/personCenter/myMessage';
import ChangeUserInfo from './pages/personCenter/changeUserInfo';
import ChooseUserInfo from './pages/personCenter/chooseUserInfo';
import Detail from './pages/community/detail';
import IntegralShop from './pages/personCenter/integralShop';
import PlateList from './pages/community/plateList';
import PlateName from './pages/community/plateName';
import SubmitSuccess from './pages/community/submitSuccess';
import FloorDetail from './pages/community/floorDetail';
import Search from './pages/community/search';
import Post from './pages/community/post';
import aboutUs from './pages/personCenter/aboutUs';
import UserAgreement from './pages/login/userAgreement'
import MyContribution from './pages/personCenter/myContribution'
//tabbar
const First = TabNavigator({
Home: { screen:Home},
SafeEscort:{screen:SafeEscort},
EventReport: { screen:EventReport},
Community: { screen:Community},
Volunteer: { screen:Volunteer},
}, {
tabBarOptions: {
activeTintColor: '#367bf0',
activeBackgroundColor:'#ffffff',
inactiveBackgroundColor:'#ffffff',
labelStyle:{
fontSize:12
},
style:{
backgroundColor: '#fff',
}
},
tabBarPosition: 'bottom',
showIcon: true,
swipeEnabled:false,
});
const Navigator = StackNavigator(
{
SignIn:{screen:SignIn},
Register:{screen:Register},
ForgetPwd:{screen:ForgetPwd},
UserAgreement:{screen:UserAgreement},
Root:{screen:First},
PersonCenter:{screen:PersonCenter},
Info:{screen:Info},
MyEvents:{screen:MyEvents},
myMessage:{screen:myMessage},
ChangeUserInfo:{screen:ChangeUserInfo},
ChooseUserInfo:{screen:ChooseUserInfo},
Detail:{screen:Detail},
IntegralShop:{screen:IntegralShop},
PlateList:{screen:PlateList},
PlateName:{screen:PlateName},
SubmitSuccess:{screen:SubmitSuccess},
FloorDetail:{screen:FloorDetail},
Search:{screen:Search},
Post:{screen:Post},
aboutUs:{screen:aboutUs},
MyContribution:{screen:MyContribution},
},
{
navigationOptions:{
headerStyle:{
paddingTop:getHeaderPadding(),
height:getHeaderHeight(),
backgroundColor:'#f8f8f8',
},
headerTitleStyle:{
alignSelf:'center',
alignItems:'center',
justifyContent:'center',
flexDirection:'column',
color:'#000',
fontSize:18,
fontWeight:'bold',
},
}
},
);
const defaultGetStateForAction = Navigator.router.getStateForAction;
Navigator.router.getStateForAction = (action,state) => {
if(action.routeName && action.routeName == 'Root'){
return defaultGetStateForAction(NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({routeName: 'Root'})
]
}))
}else{
return defaultGetStateForAction(action,state);
}
};
export default class Index extends Component{
constructor(props){
super(props);
this.state = {
loading:true
};
global.forumId = '983640534910636033';
};
componentWillMount(){
NativeModules.BlueToolManage.getCurrentStatus().then((data) => {
if(data == '1'){
this.getPhoneNumber();
}else if(data == '0'){
this.setState({
loading:false
});
}
})
};
componentDidMount() {
setTimeout(() => {
SplashScreen.hide();
}, 2000);
}
getPhoneNumber(){
NativeModules.BlueToolManage.getPhoneNumber().then((number) => {
global.phoneNumber = number;
this.setState({
loading:false
});
})
}
render(){
return(
<View style={styles.root}>
{!this.state.loading && <Navigator />}
</View>
);
}
}
const styles = StyleSheet.create({
root:{
flex:1,
marginBottom:getFooterBottom(),
}
});