forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome.js
More file actions
102 lines (84 loc) · 2.07 KB
/
Home.js
File metadata and controls
102 lines (84 loc) · 2.07 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
import React, {
Component,
PropTypes,
View,
Text,
StyleSheet,
Dimensions,
Animated,
Easing,
StatusBar
} from 'react-native';
import UserOverlay from '../components/UserOverlay';
import MessageOverlay from '../components/MessageOverlay';
import ScrollableTabs from '../components/ScrollableTabs';
import * as TopicListComponent from './TopicList';
import * as Tabs from '../constants/Tabs';
import connectComponent from '../utils/connectComponent';
const TopicList = connectComponent(TopicListComponent);
const {height, width} = Dimensions.get('window');
class Home extends Component {
componentDidMount() {
const {actions} = this.props;
actions.updateTopicsByTab('all');
}
_onPageChanged(page) {
const {actions, topic, ui} = this.props;
const tab = Tabs.tabs[page];
if (topic[tab] && ui[tab] && !ui[tab].flag) {
actions.updateTopicsByTab(tab);
}
}
_renderTopicList() {
return ['good', 'ask', 'all', 'share', 'job'].map((item)=> {
return (
<TopicList router={this.props.router}
key={item}
tab={item}/>
);
});
}
render() {
const {router, user, message} = this.props;
return (
<View style={styles.container}>
<ScrollableTabs
index={0}
tabs={['精华', '问答', '主页', '分享', '招聘']}
onPageChangedAndAnimateEnd={this._onPageChanged.bind(this)}
>
{ this._renderTopicList() }
</ScrollableTabs>
<UserOverlay user={user.secret} toLogin={() => router.toLogin() }
toUser={() => router.toUser({
userName: user.publicInfo.loginname
})}/>
<MessageOverlay user={user.secret}
count={ message.unreadMessageCount }
toMessage={ () => router.toMessage() }/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'transparent',
flex: 1
},
bg: {
width,
height,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
}
});
export const LayoutComponent = Home;
export function mapStateToProps(state) {
return {
user: state.user,
message: state.message,
topic: state.topic,
ui: state.home
}
}