UserThatNotMeContainer.js
3.98 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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
import Immutable, {Map} from 'immutable';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Actions} from 'react-native-router-flux';
import UserThatNotMe from '../components/userThatNotMe/UserThatNotMe';
import UserNavBar from '../components/user/UserNavBar';
import * as userThatNotMeActions from '../reducers/userThatNotMe/userThatNotMeActions';
import * as homeActions from '../reducers/home/homeActions';
import * as appActions from '../reducers/app/appActions';
const {
StatusBar,
ScrollView,
View,
StyleSheet,
Dimensions,
Platform,
ActionSheetIOS,
InteractionManager,
Animated,
} = ReactNative;
const actions = [
userThatNotMeActions,
homeActions,
appActions,
];
function mapStateToProps(state) {
return {
...state
};
}
function mapDispatchToProps(dispatch) {
const creators = Map()
.merge(...actions)
.filter(value => typeof value === 'function')
.toObject();
return {
actions: bindActionCreators(creators, dispatch),
dispatch
}
}
class UserThatNotMeContainer extends React.Component {
constructor(props) {
super(props);
this._onPressPost = this._onPressPost.bind(this);
this._onPressAvatar = this._onPressAvatar.bind(this);
this._onPressSectionTag = this._onPressSectionTag.bind(this);
this._onPressComment = this._onPressComment.bind(this);
this._onPressLike = this._onPressLike.bind(this);
this._onEndReached = this._onEndReached.bind(this);
this.sid = this.props.userThatNotMe.sid;
}
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
this.props.actions.getUserThatNotMeInfo(this.sid);
});
this._onEndReached();
}
componentWillUnmount() {
this.props.actions.userThatNotMeClean(this.sid);
}
_onPressAvatar(uid) {
}
_onPressSectionTag(section) {
this.props.actions.goToSection(section);
}
_onPressComment(id) {
this.props.actions.goToPost(id);
}
_onPressLike(post) {
this.props.actions.likeOperation(post);
}
_onPressPost(id) {
this.props.actions.goToPost(id);
}
_onEndReached() {
InteractionManager.runAfterInteractions(() => {
this.props.actions.userThatNotMePosts(this.sid);
});
}
render() {
let userThatNotMe = this.props.userThatNotMe.items.get(this.sid);
if (!userThatNotMe) {
__DEV__ && console.log('=========illegal state=========');
return <UserNavBar
scrollValue={new Animated.Value(0)}
channel={this.props.app.channel}
useDefault={true}
/>;
}
let {profile, posts} = userThatNotMe;
let postsData = Immutable.fromJS(posts.list);
return (
<View style={styles.container}>
<UserThatNotMe
channel={this.props.app.channel}
user={profile}
posts={postsData}
isFetching={posts.isFetching}
endReached={posts.endReached}
isLoadingMore={posts.isFetching}
onEndReached={this._onEndReached}
onPressAvatar={this._onPressAvatar}
onPressSectionTag={this._onPressSectionTag}
onPressComment={this._onPressComment}
onPressLike={this._onPressLike}
onPressPost={this._onPressPost}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let navbarHeight = (Platform.OS === 'android') ? 50 : 64;
let styles = StyleSheet.create({
container: {
top: 0,
marginBottom: 0,
flex: 1,
},
});
export default connect(mapStateToProps, mapDispatchToProps)(UserThatNotMeContainer);