index.js
2.31 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
/**
* Created by Cassie on 208/03/21.
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
NativeModules,
AsyncStorage
} from 'react-native';
import {StackNavigator,TabNavigator,NavigationActions} from 'react-navigation';
import {getHeaderHeight,getHeaderPadding,getFooterBottom} from "./utils/utils";
import SignIn from "./pages/signIn";
import Register from "./pages/register";
import ForgetPwd from "./pages/forgetPwd";
import Home from "./pages/home";
const Navigator = StackNavigator(
{
// SignIn:{screen:SignIn},
// Register:{screen:Register},
// ForgetPwd:{screen:ForgetPwd},
Home:{screen:Home}
},
{
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 == 'Home'){
return defaultGetStateForAction(NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({routeName: 'Home'})
]
}))
}else{
return defaultGetStateForAction(action,state);
}
};
export default class Index extends Component{
constructor(props){
super(props);
this.state = {
loading:false
};
};
componentWillMount(){
// NativeModules.BlueToolManage.getPhoneNumber().then((number) => {
// AsyncStorage.setItem('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(),
}
});