main.js
3.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
import React, { Component } from "react";
import {
AppRegistry,
StyleSheet,
Text,
View,
TabBarIOS,
NavigatorIOS,
Dimensions
} from "react-native";
import Home from "./Home/index";
import InsuranceCircle from "./InsuranceCircle/index";
import InsuranceChurch from "./InsuranceChurch/index";
import Mine from "./Mine/index";
import Login from "./Login";
var scale = Dimensions.get("window").scale;
export default class Main extends Component {
constructor(props) {
super(props);
this.state = {
selectedItem: "home",
};
}
componentWillMount() {
console.log("loginSuccess", this.props);
}
render() {
const { loginSuccess } = this.props;
return loginSuccess ? (
<TabBarIOS tintColor="#08CC6A" barTintColor="white">
<TabBarIOS.Item
title="首页"
icon={require("../assets/tabbar/ic_home_n.png")}
selected={this.state.selectedItem == "home"}
onPress={() => {
this.setState({
selectedItem: "home"
});
}}
>
<NavigatorIOS
style={{ flex: 1 }}
initialRoute={{
component: Home,
title: "首页",
}}
/>
</TabBarIOS.Item>
<TabBarIOS.Item
title="保圈"
icon={require("../assets/tabbar/ic_circle_n.png")}
selected={this.state.selectedItem == "insuranceCircle"}
onPress={() => {
this.setState({
selectedItem: "insuranceCircle"
});
}}
>
<NavigatorIOS
style={{ flex: 1 }}
initialRoute={{
component: InsuranceCircle,
title: "保圈",
}}
/>
</TabBarIOS.Item>
<TabBarIOS.Item
title="保堂"
icon={require("../assets/tabbar/ic_umbrella_n.png")}
selected={this.state.selectedItem == "insuranceChurch"}
onPress={() => {
this.setState({
selectedItem: "insuranceChurch"
});
}}
>
<NavigatorIOS
style={{ flex: 1 }}
initialRoute={{
component: InsuranceChurch,
title: "保堂"
}}
/>
</TabBarIOS.Item>
<TabBarIOS.Item
title="我的"
icon={require("../assets/tabbar/ic_mine_n.png")}
selected={this.state.selectedItem == "mine"}
onPress={() => {
this.setState({
selectedItem: "mine"
});
}}
>
<NavigatorIOS
style={{ flex: 1 }}
initialRoute={{
component: Mine,
title: "我的",
passProps: {
onLogin: this.props.onLogin
}
}}
/>
</TabBarIOS.Item>
</TabBarIOS>
) : (
<Login
loginSuccess={this.props.loginSuccess}
onLogin={this.props.onLogin}
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#F5FCFF"
}
});