添加社区个人中心代码。code review by 于良
Showing
8 changed files
with
583 additions
and
76 deletions
@@ -7,6 +7,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; | @@ -7,6 +7,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; | ||
7 | 7 | ||
8 | import UserCenterTop from './user/UserCenterTop'; | 8 | import UserCenterTop from './user/UserCenterTop'; |
9 | import CommunityList from './CommonComp/CommunityList'; | 9 | import CommunityList from './CommonComp/CommunityList'; |
10 | +import ReplyList from './user/ReplyList'; | ||
10 | import ParallaxView from './CommonComp/ParallaxView'; | 11 | import ParallaxView from './CommonComp/ParallaxView'; |
11 | 12 | ||
12 | 13 | ||
@@ -18,6 +19,7 @@ const { | @@ -18,6 +19,7 @@ const { | ||
18 | Dimensions, | 19 | Dimensions, |
19 | StyleSheet, | 20 | StyleSheet, |
20 | PanResponder, | 21 | PanResponder, |
22 | + ActionSheetIOS, | ||
21 | } = ReactNative; | 23 | } = ReactNative; |
22 | 24 | ||
23 | export default class User extends React.Component { | 25 | export default class User extends React.Component { |
@@ -86,8 +88,8 @@ export default class User extends React.Component { | @@ -86,8 +88,8 @@ export default class User extends React.Component { | ||
86 | 88 | ||
87 | blocks: ImmutablePropTypes.listOf( | 89 | blocks: ImmutablePropTypes.listOf( |
88 | ImmutablePropTypes.contains({ | 90 | ImmutablePropTypes.contains({ |
89 | - commentId: React.PropTypes.string, | ||
90 | - orderBy: React.PropTypes.string, | 91 | + commentId: React.PropTypes.number, |
92 | + orderBy: React.PropTypes.number, | ||
91 | content: React.PropTypes.string, | 93 | content: React.PropTypes.string, |
92 | templateKey: React.PropTypes.string.isRequired, | 94 | templateKey: React.PropTypes.string.isRequired, |
93 | }) | 95 | }) |
@@ -95,20 +97,20 @@ export default class User extends React.Component { | @@ -95,20 +97,20 @@ export default class User extends React.Component { | ||
95 | 97 | ||
96 | reply: ImmutablePropTypes.contains({ | 98 | reply: ImmutablePropTypes.contains({ |
97 | headIcon: React.PropTypes.string, | 99 | headIcon: React.PropTypes.string, |
98 | - uid: React.PropTypes.string, | 100 | + uid: React.PropTypes.number, |
99 | name: React.PropTypes.string, | 101 | name: React.PropTypes.string, |
100 | }), | 102 | }), |
101 | 103 | ||
102 | replyTo: ImmutablePropTypes.contains({ | 104 | replyTo: ImmutablePropTypes.contains({ |
103 | headIcon: React.PropTypes.string, | 105 | headIcon: React.PropTypes.string, |
104 | - uid: React.PropTypes.string, | 106 | + uid: React.PropTypes.number, |
105 | name: React.PropTypes.string, | 107 | name: React.PropTypes.string, |
106 | }), | 108 | }), |
107 | 109 | ||
108 | - id: React.PropTypes.string, | ||
109 | - postId: React.PropTypes.string, | ||
110 | - createTime: React.PropTypes.string.isRequired, | ||
111 | - authorUid: React.PropTypes.string, | 110 | + id: React.PropTypes.number, |
111 | + postId: React.PropTypes.number, | ||
112 | + createTime: React.PropTypes.number.isRequired, | ||
113 | + authorUid: React.PropTypes.number, | ||
112 | 114 | ||
113 | 115 | ||
114 | }), | 116 | }), |
@@ -117,9 +119,12 @@ export default class User extends React.Component { | @@ -117,9 +119,12 @@ export default class User extends React.Component { | ||
117 | 119 | ||
118 | }), | 120 | }), |
119 | 121 | ||
120 | - onPressAvatar: React.PropTypes.func, | 122 | + |
123 | + | ||
124 | + onPressUserAvatar: React.PropTypes.func, | ||
121 | onPressComment: React.PropTypes.func, | 125 | onPressComment: React.PropTypes.func, |
122 | onPressLike: React.PropTypes.func, | 126 | onPressLike: React.PropTypes.func, |
127 | + onPressPosts: React.PropTypes.func, | ||
123 | }; | 128 | }; |
124 | 129 | ||
125 | 130 | ||
@@ -127,12 +132,25 @@ export default class User extends React.Component { | @@ -127,12 +132,25 @@ export default class User extends React.Component { | ||
127 | super (props); | 132 | super (props); |
128 | } | 133 | } |
129 | 134 | ||
135 | + _showModifyUserInfoActionSheet() { | ||
136 | + | ||
137 | + } | ||
138 | + | ||
139 | + _showModifyBackgroundImgActionSheet() { | ||
140 | + | ||
141 | + } | ||
142 | + | ||
130 | render() { | 143 | render() { |
131 | return ( | 144 | return ( |
132 | 145 | ||
133 | <View style={styles.container}> | 146 | <View style={styles.container}> |
134 | 147 | ||
135 | - <UserCenterTop/> | 148 | + <UserCenterTop |
149 | + userInfo={this.props.dataBlob.userInfo} | ||
150 | + onPressUserAvatar={this.props.onPressUserAvatar} | ||
151 | + onPressBackgroundImg={this.props.onPressBackgroundImg} | ||
152 | + | ||
153 | + /> | ||
136 | 154 | ||
137 | <ScrollableTabView style={styles.bottom}> | 155 | <ScrollableTabView style={styles.bottom}> |
138 | <CommunityList | 156 | <CommunityList |
@@ -165,17 +183,17 @@ export default class User extends React.Component { | @@ -165,17 +183,17 @@ export default class User extends React.Component { | ||
165 | 183 | ||
166 | /> | 184 | /> |
167 | 185 | ||
168 | - <CommunityList | 186 | + <ReplyList |
169 | tabLabel="我的回复" | 187 | tabLabel="我的回复" |
170 | jsonData={this.props.dataBlob.reply} | 188 | jsonData={this.props.dataBlob.reply} |
171 | onPressAvatar={(url) => { | 189 | onPressAvatar={(url) => { |
172 | this.props.onPressAvatar && this.props.onPressAvatar(url); | 190 | this.props.onPressAvatar && this.props.onPressAvatar(url); |
173 | }} | 191 | }} |
174 | - onPressComment={(url) => { | ||
175 | - this.props.onPressComment && this.props.onPressComment(url); | 192 | + onPressReply={(url) => { |
193 | + this.props.onPressReply && this.props.onPressReply(url); | ||
176 | }} | 194 | }} |
177 | - onPressLike={(url) => { | ||
178 | - this.props.onPressLike && this.props.onPressLike(url); | 195 | + onPressPosts={(url) => { |
196 | + this.props.onPressPosts && this.props.onPressPosts(url); | ||
179 | }} | 197 | }} |
180 | 198 | ||
181 | /> | 199 | /> |
js/community/components/user/ReplyCell.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import ImmutablePropTypes from 'react-immutable-proptypes'; | ||
6 | +import UserBrief from '../home/UserBrief'; | ||
7 | +// import Thumbs from './Thumbs'; | ||
8 | +// import SectionItem from './SectionItem'; | ||
9 | +// import NumberButton from './NumberButton'; | ||
10 | +const { | ||
11 | + View, | ||
12 | + Text, | ||
13 | + Image, | ||
14 | + TouchableOpacity, | ||
15 | + StyleSheet, | ||
16 | + Dimensions, | ||
17 | +} = ReactNative; | ||
18 | + | ||
19 | +export default class ReplyCell extends React.Component { | ||
20 | + | ||
21 | + static propTypes = { | ||
22 | + data: ImmutablePropTypes.contains({ | ||
23 | + | ||
24 | + id: React.PropTypes.number, | ||
25 | + postId: React.PropTypes.number, | ||
26 | + createTime: React.PropTypes.number.isRequired, | ||
27 | + authorUid: React.PropTypes.number, | ||
28 | + | ||
29 | + // 帖子 | ||
30 | + postInfo: ImmutablePropTypes.contains({ | ||
31 | + title: React.PropTypes.string, | ||
32 | + type: React.PropTypes.string.isRequired, | ||
33 | + }), | ||
34 | + | ||
35 | + // 回复的内容 | ||
36 | + blocks: ImmutablePropTypes.listOf( | ||
37 | + ImmutablePropTypes.contains({ | ||
38 | + commentId: React.PropTypes.number, | ||
39 | + orderBy: React.PropTypes.number, | ||
40 | + content: React.PropTypes.string, | ||
41 | + templateKey: React.PropTypes.string.isRequired, | ||
42 | + }) | ||
43 | + ), | ||
44 | + | ||
45 | + // 我的信息 | ||
46 | + reply: ImmutablePropTypes.contains({ | ||
47 | + headIcon: React.PropTypes.string, | ||
48 | + uid: React.PropTypes.number, | ||
49 | + name: React.PropTypes.string, | ||
50 | + }), | ||
51 | + | ||
52 | + // 被回复者信息 | ||
53 | + replyTo: ImmutablePropTypes.contains({ | ||
54 | + headIcon: React.PropTypes.string, | ||
55 | + uid: React.PropTypes.number, | ||
56 | + name: React.PropTypes.string, | ||
57 | + }), | ||
58 | + | ||
59 | + onPressAvatar: React.PropTypes.func, | ||
60 | + onPressReply: React.PropTypes.func, | ||
61 | + onPressPosts: React.PropTypes.func, | ||
62 | + | ||
63 | + }), | ||
64 | + | ||
65 | + // TODO 添加点击事件 | ||
66 | + | ||
67 | + }; | ||
68 | + | ||
69 | + constructor(props) { | ||
70 | + super(props); | ||
71 | + } | ||
72 | + | ||
73 | + render() { | ||
74 | + let data = this.props.data.toJS(); | ||
75 | + let { | ||
76 | + id, | ||
77 | + postId, | ||
78 | + createTime, | ||
79 | + authorUid, | ||
80 | + postInfo, | ||
81 | + blocks, | ||
82 | + reply, | ||
83 | + replyTo, | ||
84 | + } = data; | ||
85 | + | ||
86 | + return ( | ||
87 | + <View style={styles.container}> | ||
88 | + <View style={styles.topContainer}> | ||
89 | + <UserBrief | ||
90 | + avatar={reply.headIcon} | ||
91 | + name={reply.name} | ||
92 | + timeago={createTime.toString()} | ||
93 | + // isOwner={isOwner} | ||
94 | + onPressAvatar={() => { | ||
95 | + this.props.onPressAvatar && this.props.onPressAvatar(); | ||
96 | + }} | ||
97 | + /> | ||
98 | + | ||
99 | + </View> | ||
100 | + | ||
101 | + <View style={styles.reply}> | ||
102 | + <Text style={[styles.text,{fontSize:14}]}> | ||
103 | + 回复 | ||
104 | + | ||
105 | + <Text style={{color: '#4a90e2', fontSize: 14,}} | ||
106 | + onPress={() => { | ||
107 | + this.props.onPressReply && this.props.onPressReply(); | ||
108 | + }} | ||
109 | + > | ||
110 | + 小草莓 | ||
111 | + </Text> | ||
112 | + | ||
113 | + | ||
114 | + | ||
115 | + :如果你无法表单房间诶哦我就佛大发了瓦解偶发的拉萨减肥劳动局撒了附件二范德萨范德萨 | ||
116 | + </Text> | ||
117 | + </View> | ||
118 | + | ||
119 | + <View style={styles.lineInCell}/> | ||
120 | + | ||
121 | + <View style={styles.bottomContainer}> | ||
122 | + <Text | ||
123 | + style={[styles.text,{margin:15, fontSize: 18}]} | ||
124 | + numberOfLines={1} | ||
125 | + onPress={() => { | ||
126 | + this.props.onPressPosts && this.props.onPressPosts(); | ||
127 | + }} | ||
128 | + > | ||
129 | + 帖子:港南爱上米彩妆,看叫啥呢我发的是fdsafdsafdsafdasfd剪短发搜富哦为福建省的 | ||
130 | + </Text> | ||
131 | + </View> | ||
132 | + | ||
133 | + | ||
134 | + </View> | ||
135 | + | ||
136 | + | ||
137 | + ); | ||
138 | + | ||
139 | + } | ||
140 | +} | ||
141 | + | ||
142 | +let styles = StyleSheet.create({ | ||
143 | + container: { | ||
144 | + backgroundColor:'white', | ||
145 | + flexDirection:'column', | ||
146 | + }, | ||
147 | + | ||
148 | + topContainer: { | ||
149 | + margin: 15, | ||
150 | + }, | ||
151 | + | ||
152 | + reply: { | ||
153 | + // backgroundColor: 'red', | ||
154 | + marginLeft: 15, | ||
155 | + marginRight: 15, | ||
156 | + }, | ||
157 | + | ||
158 | + text: { | ||
159 | + fontFamily: 'Helvetica Light', | ||
160 | + }, | ||
161 | + | ||
162 | + | ||
163 | + bottomContainer: { | ||
164 | + backgroundColor:'white' | ||
165 | + }, | ||
166 | + | ||
167 | + lineInCell: { | ||
168 | + height: 1, | ||
169 | + marginLeft: 15, | ||
170 | + marginTop: 15, | ||
171 | + // marginBottom: 15, | ||
172 | + backgroundColor: '#e0e0e0', | ||
173 | + }, | ||
174 | + | ||
175 | + replyTouch: { | ||
176 | + backgroundColor: 'red', | ||
177 | + // padding: 0, | ||
178 | + width:80, | ||
179 | + height: 40, | ||
180 | + }, | ||
181 | +}); |
js/community/components/user/ReplyList.js
0 → 100644
1 | +'use strict'; | ||
2 | + | ||
3 | +import React from 'react'; | ||
4 | +import ReactNative from 'react-native'; | ||
5 | +import ReplyCell from './ReplyCell'; | ||
6 | + | ||
7 | +const { | ||
8 | + View, | ||
9 | + Text, | ||
10 | + Image, | ||
11 | + ListView, | ||
12 | + TouchableOpacity, | ||
13 | + Platform, | ||
14 | + StyleSheet, | ||
15 | + Dimensions, | ||
16 | +} = ReactNative; | ||
17 | + | ||
18 | +export default class ReplyList extends React.Component { | ||
19 | + constructor(props) { | ||
20 | + super(props); | ||
21 | + this._renderRow = this._renderRow.bind(this); | ||
22 | + this._renderSeparator = this._renderSeparator.bind(this); | ||
23 | + this.dataSource = new ListView.DataSource({ | ||
24 | + rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | ||
25 | + sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2), | ||
26 | + }); | ||
27 | + } | ||
28 | + | ||
29 | + | ||
30 | + _renderRow(rowData, sectionID, rowID, highlightRow) { | ||
31 | + return ( | ||
32 | + <ReplyCell | ||
33 | + key={sectionID + rowID} | ||
34 | + data={rowData} | ||
35 | + // onPressPost={(url) => { | ||
36 | + // this.props.onPressPost && this.props.onPressPost(url); | ||
37 | + // }} | ||
38 | + onPressAvatar={(url) => { | ||
39 | + this.props.onPressAvatar && this.props.onPressAvatar(url); | ||
40 | + }} | ||
41 | + | ||
42 | + onPressReply={(url) => { | ||
43 | + this.props.onPressReply && this.props.onPressReply(url); | ||
44 | + }} | ||
45 | + onPressPosts={(url) => { | ||
46 | + this.props.onPressPosts && this.props.onPressPosts(url); | ||
47 | + }} | ||
48 | + // onPressLike={(url) => { | ||
49 | + // this.props.onPressLike && this.props.onPressLike(url); | ||
50 | + // }} | ||
51 | + /> | ||
52 | + ); | ||
53 | + } | ||
54 | + | ||
55 | + _renderSeparator(sectionID, rowID, adjacentRowHighlighted) { | ||
56 | + return ( | ||
57 | + <View key={'separator' + sectionID + rowID} style={styles.separator}/> | ||
58 | + ); | ||
59 | + } | ||
60 | + | ||
61 | + render() { | ||
62 | + | ||
63 | + return ( | ||
64 | + <ListView | ||
65 | + dataSource={this.dataSource.cloneWithRows(this.props.jsonData)} | ||
66 | + renderRow={this._renderRow} | ||
67 | + renderSectionHeader={this._renderSectionHeader} | ||
68 | + renderSeparator={this._renderSeparator} | ||
69 | + enableEmptySections={true} | ||
70 | + /> | ||
71 | + ); | ||
72 | + | ||
73 | + } | ||
74 | + | ||
75 | + | ||
76 | +} | ||
77 | + | ||
78 | + | ||
79 | +let styles = StyleSheet.create({ | ||
80 | + | ||
81 | + separator: { | ||
82 | + height: 0.5, | ||
83 | + backgroundColor: '#e0e0e0', | ||
84 | + }, | ||
85 | +}); |
@@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
2 | 2 | ||
3 | import React from 'react'; | 3 | import React from 'react'; |
4 | import ReactNative from 'react-native'; | 4 | import ReactNative from 'react-native'; |
5 | +import ImmutablePropTypes from 'react-immutable-proptypes'; | ||
6 | + | ||
5 | 7 | ||
6 | const { | 8 | const { |
7 | View, | 9 | View, |
@@ -10,22 +12,75 @@ const { | @@ -10,22 +12,75 @@ const { | ||
10 | StyleSheet, | 12 | StyleSheet, |
11 | Dimensions, | 13 | Dimensions, |
12 | Platform, | 14 | Platform, |
15 | + TouchableOpacity, | ||
16 | + TouchableHighlight, | ||
13 | } = ReactNative; | 17 | } = ReactNative; |
14 | 18 | ||
15 | export default class UserCenterTop extends React.Component { | 19 | export default class UserCenterTop extends React.Component { |
16 | - render() { | ||
17 | 20 | ||
21 | + | ||
22 | + static propTypes = { | ||
23 | + backgroundImage: React.PropTypes.string, | ||
24 | + avatar: React.PropTypes.string, | ||
25 | + name: React.PropTypes.string.isRequired, | ||
26 | + sign: React.PropTypes.string, | ||
27 | + | ||
28 | + onPressUserAvatar: React.PropTypes.func, | ||
29 | + onPressBackgroundImg: React.PropTypes.func, | ||
30 | + }; | ||
31 | + | ||
32 | + constructor(props) { | ||
33 | + super (props); | ||
34 | + } | ||
35 | + | ||
36 | + render() { | ||
37 | + console.log('userinfo = ' + this.props.userInfo); | ||
38 | + let data = this.props.userInfo; | ||
39 | + let {backgroundImage, avatar, name, sign,} = data; | ||
18 | return ( | 40 | return ( |
41 | + | ||
42 | + | ||
19 | <View style={styles.container}> | 43 | <View style={styles.container}> |
20 | - <Image style={styles.backgroundImage} | ||
21 | - source={require('../../images/user-bg.png')} | 44 | + <TouchableHighlight |
45 | + underlayColor={'transparent'} | ||
46 | + onPress={() => { | ||
47 | + this.props.onPressBackgroundImg && this.props.onPressBackgroundImg(); | ||
48 | + }} | ||
49 | + | ||
22 | > | 50 | > |
23 | - <Image style={styles.avatarImage} | ||
24 | - source={require('../../images/avatar-default.png')} | 51 | + <Image |
52 | + style={styles.backgroundImage} | ||
53 | + source={backgroundImage} | ||
25 | > | 54 | > |
26 | 55 | ||
56 | + <TouchableOpacity | ||
57 | + onPress={() => { | ||
58 | + this.props.onPressUserAvatar && this.props.onPressUserAvatar(); | ||
59 | + }} | ||
60 | + > | ||
61 | + <Image | ||
62 | + style={styles.avatarImage} | ||
63 | + source={avatar} | ||
64 | + > | ||
65 | + | ||
66 | + </Image> | ||
67 | + | ||
68 | + </TouchableOpacity> | ||
69 | + | ||
70 | + <Text | ||
71 | + style={styles.name} | ||
72 | + > | ||
73 | + {name} | ||
74 | + </Text> | ||
75 | + | ||
76 | + <Text | ||
77 | + style={styles.sign} | ||
78 | + > | ||
79 | + {sign} | ||
80 | + </Text> | ||
27 | </Image> | 81 | </Image> |
28 | - </Image> | 82 | + |
83 | + </TouchableHighlight> | ||
29 | </View> | 84 | </View> |
30 | ); | 85 | ); |
31 | 86 | ||
@@ -39,20 +94,20 @@ let styles = StyleSheet.create({ | @@ -39,20 +94,20 @@ let styles = StyleSheet.create({ | ||
39 | container: { | 94 | container: { |
40 | 95 | ||
41 | height: 244, | 96 | height: 244, |
42 | - backgroundColor: 'green', | 97 | + backgroundColor: 'transparent', |
43 | }, | 98 | }, |
44 | 99 | ||
45 | backgroundImage: { | 100 | backgroundImage: { |
46 | // top: 0, | 101 | // top: 0, |
47 | - // flex: 1, | ||
48 | - // flexDirection: 'row', | ||
49 | - // justifyContent: 'center', | 102 | + flex: 1, |
103 | + flexDirection: 'column', | ||
104 | + justifyContent: 'center', | ||
50 | alignItems: 'center', | 105 | alignItems: 'center', |
51 | // alignItems: 'center' | 106 | // alignItems: 'center' |
52 | }, | 107 | }, |
53 | 108 | ||
54 | avatarImage: { | 109 | avatarImage: { |
55 | - top: 79, | 110 | + marginTop: 50, |
56 | width: 74, | 111 | width: 74, |
57 | height: 74, | 112 | height: 74, |
58 | borderRadius: 37, | 113 | borderRadius: 37, |
@@ -61,12 +116,23 @@ let styles = StyleSheet.create({ | @@ -61,12 +116,23 @@ let styles = StyleSheet.create({ | ||
61 | backgroundColor: 'white' | 116 | backgroundColor: 'white' |
62 | }, | 117 | }, |
63 | 118 | ||
64 | - userName: { | ||
65 | - | 119 | + name: { |
120 | + color: 'white', | ||
121 | + textAlign: 'center', | ||
122 | + margin: 15, | ||
123 | + marginBottom:10, | ||
124 | + // backgroundColor:'red', | ||
125 | + fontSize: 14, | ||
126 | + fontFamily: 'Helvetica Light', | ||
66 | }, | 127 | }, |
67 | 128 | ||
68 | - userSign: { | ||
69 | - | 129 | + sign: { |
130 | + color: 'white', | ||
131 | + textAlign: 'center', | ||
132 | + // margin: 15, | ||
133 | + // backgroundColor:'red', | ||
134 | + fontSize: 12, | ||
135 | + fontFamily: 'Helvetica Light', | ||
70 | } | 136 | } |
71 | 137 | ||
72 | }); | 138 | }); |
@@ -22,6 +22,9 @@ export default keyMirror({ | @@ -22,6 +22,9 @@ export default keyMirror({ | ||
22 | USER_REPLY_SUCCESS: null, | 22 | USER_REPLY_SUCCESS: null, |
23 | USER_REPLY_FAILURE: null, | 23 | USER_REPLY_FAILURE: null, |
24 | 24 | ||
25 | + USER_GO_TO_SETTING_STATS: null, // 个人中心页面跳转 | ||
26 | + | ||
27 | + | ||
25 | POSTING_BOARD_REQUEST: null, | 28 | POSTING_BOARD_REQUEST: null, |
26 | POSTING_BOARD_SUCCESS: null, | 29 | POSTING_BOARD_SUCCESS: null, |
27 | POSTING_BOARD_FAILURE: null, | 30 | POSTING_BOARD_FAILURE: null, |
@@ -13,12 +13,31 @@ import User from '../components/User'; | @@ -13,12 +13,31 @@ import User from '../components/User'; | ||
13 | import * as userActions from '../reducers/user/userActions'; | 13 | import * as userActions from '../reducers/user/userActions'; |
14 | 14 | ||
15 | const { | 15 | const { |
16 | + | ||
17 | + USER_POSTS_REQUEST, | ||
18 | + USER_POSTS_SUCCESS, | ||
19 | + USER_POSTS_FAILURE, | ||
20 | + | ||
21 | + USER_LIKE_REQUEST, | ||
22 | + USER_LIKE_SUCCESS, | ||
23 | + USER_LIKE_FAILURE, | ||
24 | + | ||
25 | + USER_REPLY_REQUEST, | ||
26 | + USER_REPLY_SUCCESS, | ||
27 | + USER_REPLY_FAILURE, | ||
28 | + | ||
29 | + USER_GO_TO_SETTING_STATS, | ||
30 | + | ||
31 | +} = require('../constants/actionTypes').default; | ||
32 | + | ||
33 | +const { | ||
16 | StatusBar, | 34 | StatusBar, |
17 | ScrollView, | 35 | ScrollView, |
18 | View, | 36 | View, |
19 | StyleSheet, | 37 | StyleSheet, |
20 | Dimensions, | 38 | Dimensions, |
21 | Platform, | 39 | Platform, |
40 | + ActionSheetIOS, | ||
22 | } = ReactNative; | 41 | } = ReactNative; |
23 | 42 | ||
24 | const actions = [ | 43 | const actions = [ |
@@ -46,7 +65,7 @@ function mapDispatchToProps(dispatch) { | @@ -46,7 +65,7 @@ function mapDispatchToProps(dispatch) { | ||
46 | class UserContainer extends React.Component { | 65 | class UserContainer extends React.Component { |
47 | constructor(props) { | 66 | constructor(props) { |
48 | super(props); | 67 | super(props); |
49 | - | 68 | + this._onPressUserAvatar = this._onPressUserAvatar.bind(this); |
50 | 69 | ||
51 | } | 70 | } |
52 | 71 | ||
@@ -59,6 +78,7 @@ class UserContainer extends React.Component { | @@ -59,6 +78,7 @@ class UserContainer extends React.Component { | ||
59 | } | 78 | } |
60 | 79 | ||
61 | 80 | ||
81 | + // private method | ||
62 | _onPressAvatar(url) { | 82 | _onPressAvatar(url) { |
63 | console.log('avatar'); | 83 | console.log('avatar'); |
64 | } | 84 | } |
@@ -71,15 +91,94 @@ class UserContainer extends React.Component { | @@ -71,15 +91,94 @@ class UserContainer extends React.Component { | ||
71 | console.log('like'); | 91 | console.log('like'); |
72 | } | 92 | } |
73 | 93 | ||
94 | + _onPressReply() { | ||
95 | + console.log('reply'); | ||
96 | + } | ||
97 | + | ||
98 | + _onPressPosts() { | ||
99 | + console.log('posts'); | ||
100 | + } | ||
101 | + | ||
102 | + _onPressUserAvatar() { | ||
74 | 103 | ||
104 | + const BUTTONS = ['拍照', '从相册选择', '编辑个人资料', '取消']; | ||
105 | + ActionSheetIOS.showActionSheetWithOptions({ | ||
106 | + options: BUTTONS, | ||
107 | + cancelButtonIndex: 3, | ||
108 | + }, | ||
109 | + | ||
110 | + (buttonIndex) => { | ||
111 | + // _onPressGotoSettingState(buttonIndex); | ||
112 | + // this.setState({ clicked: BUTTONS[buttonIndex] }); | ||
113 | + this.props.actions.goToStatsPage(USER_GO_TO_SETTING_STATS); | ||
114 | + | ||
115 | + }); | ||
116 | + | ||
117 | + | ||
118 | + } | ||
119 | + | ||
120 | + _onPressGotoSettingState(buttonIndex) { | ||
121 | + console.log('go to setting state'); | ||
122 | + switch (buttonIndex) { | ||
123 | + case 0: | ||
124 | + { | ||
125 | + console.log('拍照'); | ||
126 | + } | ||
127 | + break; | ||
128 | + case 1: | ||
129 | + { | ||
130 | + console.log('从相册中选择'); | ||
131 | + } | ||
132 | + break; | ||
133 | + case 2: | ||
134 | + { | ||
135 | + console.log('编辑个人资料'); | ||
136 | + console.log('actions = ' + this.actions); | ||
137 | + this.actions.goToStatsPage(USER_GO_TO_SETTING_STATS); | ||
138 | + | ||
139 | + } | ||
140 | + break; | ||
141 | + default: | ||
142 | + } | ||
143 | + } | ||
144 | + | ||
145 | + _onPressBackgroundImg() { | ||
146 | + const BUTTONS = ['拍照', '从相册选择', '取消']; | ||
147 | + ActionSheetIOS.showActionSheetWithOptions({ | ||
148 | + options: BUTTONS, | ||
149 | + cancelButtonIndex: 2, | ||
150 | + }, | ||
151 | + (buttonIndex) => { | ||
152 | + switch (buttonIndex) { | ||
153 | + case 0: | ||
154 | + { | ||
155 | + console.log('拍照'); | ||
156 | + } | ||
157 | + break; | ||
158 | + case 1: | ||
159 | + { | ||
160 | + console.log('从相册中选择'); | ||
161 | + } | ||
162 | + break; | ||
163 | + default: | ||
164 | + } | ||
165 | + }); | ||
166 | + } | ||
167 | + | ||
168 | + | ||
169 | + | ||
170 | + _fetchData() { | ||
171 | + // this.props.actions.userInfo(); | ||
172 | + // this.props.actions.posts(); | ||
173 | + } | ||
75 | 174 | ||
76 | render() { | 175 | render() { |
77 | 176 | ||
78 | let userInfo = { | 177 | let userInfo = { |
79 | avatar: require('../images/avatar-default.png'), | 178 | avatar: require('../images/avatar-default.png'), |
80 | - userName:'Arthur', | 179 | + name:'Arthur', |
81 | sign:'Hello, Bro', | 180 | sign:'Hello, Bro', |
82 | - bgImage: require('../images/user-bg.png'), | 181 | + backgroundImage: require('../images/user-bg.png'), |
83 | }; | 182 | }; |
84 | 183 | ||
85 | let posts = [ | 184 | let posts = [ |
@@ -160,12 +259,86 @@ class UserContainer extends React.Component { | @@ -160,12 +259,86 @@ class UserContainer extends React.Component { | ||
160 | }, | 259 | }, |
161 | ]; | 260 | ]; |
162 | 261 | ||
262 | + let like = [ | ||
263 | + { | ||
264 | + avatar: 'https://img11.static.yhbimg.com/yhb-img01/2016/06/28/11/01f429fffdff555ed0c141a5ec2b4fd421.jpg?imageView2/2/w/640/h/240', | ||
265 | + name: 'Arthur', | ||
266 | + timeago: '2小时前', | ||
267 | + isOwner: false, | ||
268 | + isTop: true, | ||
269 | + isLike: true, | ||
270 | + title: 'Yoho!Buy特邀摄影师大赛开始报名啦!', | ||
271 | + desc: 'MADNESS作为“六叔”余文乐的个人品牌,经过几个季度的产品表现,相信大家都知道这并不是玩票性质,而是余文乐在做心中的街头品牌。此番MADNESS正式迎来2016春夏的开季,以Los Angeles作为拍摄地点,延续余文乐一直喜欢的简约风格', | ||
272 | + thumbs: [ | ||
273 | + { | ||
274 | + url: 'https://img11.static.yhbimg.com/yhb-img01/2016/06/28/11/01f429fffdff555ed0c141a5ec2b4fd421.jpg?imageView2/2/w/640/h/240', | ||
275 | + }, | ||
276 | + { | ||
277 | + url: 'https://img11.static.yhbimg.com/yhb-img01/2016/06/28/11/01f429fffdff555ed0c141a5ec2b4fd421.jpg?imageView2/2/w/640/h/240', | ||
278 | + }, | ||
279 | + { | ||
280 | + url: 'https://img11.static.yhbimg.com/yhb-img01/2016/06/28/11/01f429fffdff555ed0c141a5ec2b4fd421.jpg?imageView2/2/w/640/h/240', | ||
281 | + } | ||
282 | + ], | ||
283 | + section: '永恒的潮流', | ||
284 | + commentCount: 123, | ||
285 | + likeCount: 45678, | ||
286 | + url: 'https://www.baidu.com' | ||
287 | + }]; | ||
288 | + | ||
289 | + let reply = [ | ||
290 | + { | ||
291 | + "postInfo": { | ||
292 | + "title": "害怕抢不到NMD?别担心,至少他们都不是你的对手!", | ||
293 | + "type": "text" | ||
294 | + }, | ||
295 | + "createTime": 1467189316, | ||
296 | + "authorUid": 0, | ||
297 | + "blocks": [ | ||
298 | + { | ||
299 | + "commentId": 52, | ||
300 | + "orderBy": 0, | ||
301 | + "content": "永远的18岁!!!", | ||
302 | + "templateKey": "text" | ||
303 | + }, | ||
304 | + { | ||
305 | + "commentId": 52, | ||
306 | + "orderBy": 0, | ||
307 | + "content": "http://img12.static.yhbimg.com/goodsimg/2016/06/06/05/02e8b4a63c0101b1a1a8f04b53d817b9d4.png", | ||
308 | + "templateKey": "image" | ||
309 | + }, | ||
310 | + { | ||
311 | + "commentId": 52, | ||
312 | + "orderBy": 1, | ||
313 | + "content": "http://img12.static.yhbimg.com/goodsimg/2016/06/06/05/02e8b4a63c0101b1a1a8f04b53d817b9d5.png", | ||
314 | + "templateKey": "image" | ||
315 | + } | ||
316 | + ], | ||
317 | + "replyTo": { | ||
318 | + "headIcon": "https://img11.static.yhbimg.com/yhb-img01/2016/06/28/11/01f429fffdff555ed0c141a5ec2b4fd421.jpg?imageView2/2/w/640/h/240", | ||
319 | + "uid": 8050829, | ||
320 | + "name": "petch" | ||
321 | + }, | ||
322 | + "id": 52, | ||
323 | + "postId": 80, | ||
324 | + "reply": { | ||
325 | + "headIcon": "https://img11.static.yhbimg.com/yhb-img01/2016/06/28/11/01f429fffdff555ed0c141a5ec2b4fd421.jpg?imageView2/2/w/640/h/240", | ||
326 | + "uid": 8050829, | ||
327 | + "name": "petch" | ||
328 | + }, | ||
329 | + "status": 0 | ||
330 | + } | ||
331 | + ]; | ||
332 | + | ||
333 | + | ||
163 | 334 | ||
164 | let dataBlob = { | 335 | let dataBlob = { |
165 | userInfo: Immutable.fromJS(userInfo).toObject(), | 336 | userInfo: Immutable.fromJS(userInfo).toObject(), |
166 | // notice: Immutable.fromJS(notice).toObject(), | 337 | // notice: Immutable.fromJS(notice).toObject(), |
167 | // section: Immutable.fromJS(section).toObject(), | 338 | // section: Immutable.fromJS(section).toObject(), |
168 | posts: Immutable.fromJS(posts).toArray(), | 339 | posts: Immutable.fromJS(posts).toArray(), |
340 | + like: Immutable.fromJS(like).toArray(), | ||
341 | + reply: Immutable.fromJS(reply).toArray(), | ||
169 | }; | 342 | }; |
170 | 343 | ||
171 | return ( | 344 | return ( |
@@ -179,16 +352,15 @@ class UserContainer extends React.Component { | @@ -179,16 +352,15 @@ class UserContainer extends React.Component { | ||
179 | onPressAvatar={this._onPressAvatar} | 352 | onPressAvatar={this._onPressAvatar} |
180 | onPressComment={this._onPressComment} | 353 | onPressComment={this._onPressComment} |
181 | onPressLike={this._onPressLike} | 354 | onPressLike={this._onPressLike} |
355 | + onPressReply={this._onPressReply} | ||
356 | + onPressPosts={this._onPressPosts} | ||
357 | + onPressUserAvatar={this._onPressUserAvatar} | ||
358 | + onPressBackgroundImg={this._onPressBackgroundImg} | ||
182 | /> | 359 | /> |
183 | </View> | 360 | </View> |
184 | ); | 361 | ); |
185 | } | 362 | } |
186 | 363 | ||
187 | - // private method | ||
188 | - _fetchData() { | ||
189 | - // this.props.actions.userInfo(); | ||
190 | - // this.props.actions.posts(); | ||
191 | - } | ||
192 | } | 364 | } |
193 | 365 | ||
194 | let {width, height} = Dimensions.get('window'); | 366 | let {width, height} = Dimensions.get('window'); |
@@ -18,6 +18,8 @@ const { | @@ -18,6 +18,8 @@ const { | ||
18 | USER_REPLY_SUCCESS, | 18 | USER_REPLY_SUCCESS, |
19 | USER_REPLY_FAILURE, | 19 | USER_REPLY_FAILURE, |
20 | 20 | ||
21 | + USER_GO_TO_SETTING_STATS, | ||
22 | + | ||
21 | } = require('../../constants/actionTypes').default; | 23 | } = require('../../constants/actionTypes').default; |
22 | 24 | ||
23 | export function postRequest() { | 25 | export function postRequest() { |
@@ -135,43 +137,18 @@ export function reply() { | @@ -135,43 +137,18 @@ export function reply() { | ||
135 | }; | 137 | }; |
136 | } | 138 | } |
137 | 139 | ||
138 | -//测试数据 | ||
139 | -let postsTestData = { | ||
140 | - sum: '100', | ||
141 | - currentPage: 1, | ||
142 | - pageCount: 1, | ||
143 | - list: [ | ||
144 | - { | ||
145 | - name: 'Arthur', | ||
146 | - title: '这是一篇文章', | ||
147 | - brief: '简介', | ||
148 | - topic: '复古市集会', | ||
149 | - imgs: ['https://facebook.github.io/react/img/logo_og.png'], | ||
150 | - }, | ||
151 | - { | ||
152 | - name: 'Arthur', | ||
153 | - title: '这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章', | ||
154 | - brief: '简介', | ||
155 | - imgs: ['https://facebook.github.io/react/img/logo_og.png', 'https://facebook.github.io/react/img/logo_og.png'], | ||
156 | - }, | ||
157 | - { | ||
158 | - name: 'Arthur', | ||
159 | - title: '这是一篇文章', | ||
160 | - brief: '简介这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章这是一篇文章', | ||
161 | - imgs: ['https://facebook.github.io/react/img/logo_og.png','https://facebook.github.io/react/img/logo_og.png', 'https://facebook.github.io/react/img/logo_og.png'], | ||
162 | - | ||
163 | - }, | ||
164 | - { | ||
165 | - name: 'Arthur', | ||
166 | - title: '这是一篇文章', | ||
167 | - brief: '简介', | ||
168 | - imgs: ['https://facebook.github.io/react/img/logo_og.png','https://facebook.github.io/react/img/logo_og.png', 'https://facebook.github.io/react/img/logo_og.png'], | ||
169 | - }, | 140 | +// 页面跳转 |
141 | +export function goToStatsPage(type) { | ||
142 | + switch (type) { | ||
143 | + case USER_GO_TO_SETTING_STATS: | ||
170 | { | 144 | { |
171 | - name: 'Arthur', | ||
172 | - title: '这是一篇文章', | ||
173 | - // brief: '简介', | ||
174 | - imgs: ['https://facebook.github.io/react/img/logo_og.png','https://facebook.github.io/react/img/logo_og.png', 'https://facebook.github.io/react/img/logo_og.png'], | ||
175 | - }, | ||
176 | - ] | 145 | + Actions.SettingStats(); |
146 | + return { | ||
147 | + type: USER_GO_TO_SETTING_STATS, | ||
148 | + } | ||
149 | + } | ||
150 | + break; | ||
151 | + default: | ||
152 | + | ||
153 | + } | ||
177 | } | 154 | } |
@@ -19,6 +19,8 @@ const { | @@ -19,6 +19,8 @@ const { | ||
19 | USER_REPLY_SUCCESS, | 19 | USER_REPLY_SUCCESS, |
20 | USER_REPLY_FAILURE, | 20 | USER_REPLY_FAILURE, |
21 | 21 | ||
22 | + USER_GO_TO_SETTING_STATS, | ||
23 | + | ||
22 | } = require('../../constants/actionTypes').default; | 24 | } = require('../../constants/actionTypes').default; |
23 | 25 | ||
24 | const initialState = new InitialState; | 26 | const initialState = new InitialState; |
@@ -62,6 +64,9 @@ export default function user(state = initialState, action) { | @@ -62,6 +64,9 @@ export default function user(state = initialState, action) { | ||
62 | return nextState; | 64 | return nextState; |
63 | } | 65 | } |
64 | 66 | ||
67 | + case USER_GO_TO_SETTING_STATS: | ||
68 | + return state; | ||
69 | + | ||
65 | default: | 70 | default: |
66 | 71 | ||
67 | } | 72 | } |
-
Please register or login to post a comment