修改种草消息tab切小红点数字 reviewd by 朱傲哲
Showing
6 changed files
with
53 additions
and
17 deletions
@@ -18,11 +18,19 @@ export default class ContentListView extends Component { | @@ -18,11 +18,19 @@ export default class ContentListView extends Component { | ||
18 | super(props); | 18 | super(props); |
19 | 19 | ||
20 | this._renderRow = this._renderRow.bind(this); | 20 | this._renderRow = this._renderRow.bind(this); |
21 | + this._renderFooter = this._renderFooter.bind(this); | ||
21 | this.dataSource = new ListView.DataSource({ | 22 | this.dataSource = new ListView.DataSource({ |
22 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | 23 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), |
23 | }); | 24 | }); |
24 | } | 25 | } |
25 | 26 | ||
27 | + _renderFooter(){ | ||
28 | + return ( | ||
29 | + <View style={[{height: 50}, {backgroundColor: 'white'}, {justifyContent:'center'}]}> | ||
30 | + </View> | ||
31 | + ) | ||
32 | + } | ||
33 | + | ||
26 | _renderRow(rowData, sectionID, rowID) { | 34 | _renderRow(rowData, sectionID, rowID) { |
27 | 35 | ||
28 | return ( | 36 | return ( |
@@ -76,6 +84,7 @@ export default class ContentListView extends Component { | @@ -76,6 +84,7 @@ export default class ContentListView extends Component { | ||
76 | contentContainerStyle={styles.contentContainer} | 84 | contentContainerStyle={styles.contentContainer} |
77 | dataSource={this.dataSource.cloneWithRows(contentList)} | 85 | dataSource={this.dataSource.cloneWithRows(contentList)} |
78 | renderRow={this._renderRow} | 86 | renderRow={this._renderRow} |
87 | + renderFooter={this._renderFooter} | ||
79 | enableEmptySections={true} | 88 | enableEmptySections={true} |
80 | enablePullToRefresh={true} | 89 | enablePullToRefresh={true} |
81 | isOnPullToRefresh={isPullToRefresh} | 90 | isOnPullToRefresh={isPullToRefresh} |
@@ -96,6 +105,7 @@ export default class ContentListView extends Component { | @@ -96,6 +105,7 @@ export default class ContentListView extends Component { | ||
96 | contentContainerStyle={styles.contentContainer} | 105 | contentContainerStyle={styles.contentContainer} |
97 | dataSource={this.dataSource.cloneWithRows(contentList)} | 106 | dataSource={this.dataSource.cloneWithRows(contentList)} |
98 | renderRow={this._renderRow} | 107 | renderRow={this._renderRow} |
108 | + renderFooter={this._renderFooter} | ||
99 | enableEmptySections={true} | 109 | enableEmptySections={true} |
100 | enablePullToRefresh={true} | 110 | enablePullToRefresh={true} |
101 | refreshControl={ | 111 | refreshControl={ |
@@ -18,6 +18,7 @@ export default class ContentMessageView extends Component { | @@ -18,6 +18,7 @@ export default class ContentMessageView extends Component { | ||
18 | 18 | ||
19 | this._renderRow = this._renderRow.bind(this); | 19 | this._renderRow = this._renderRow.bind(this); |
20 | this._renderHeader = this._renderHeader.bind(this); | 20 | this._renderHeader = this._renderHeader.bind(this); |
21 | + this._renderFooter = this._renderFooter.bind(this); | ||
21 | this.dataSource = new ListView.DataSource({ | 22 | this.dataSource = new ListView.DataSource({ |
22 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), | 23 | rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), |
23 | }); | 24 | }); |
@@ -42,10 +43,6 @@ export default class ContentMessageView extends Component { | @@ -42,10 +43,6 @@ export default class ContentMessageView extends Component { | ||
42 | NativeModules.YH_CommonHelper.jumpToUpdateNotificationStatus(); | 43 | NativeModules.YH_CommonHelper.jumpToUpdateNotificationStatus(); |
43 | } | 44 | } |
44 | 45 | ||
45 | - function onPress(actionUrl) { | ||
46 | - NativeModules.YH_CommonHelper.jumpWithUrl(actionUrl); | ||
47 | - } | ||
48 | - | ||
49 | return (<View> | 46 | return (<View> |
50 | {showStatus ? | 47 | {showStatus ? |
51 | <View style={styles.tipContainer}> | 48 | <View style={styles.tipContainer}> |
@@ -62,7 +59,7 @@ export default class ContentMessageView extends Component { | @@ -62,7 +59,7 @@ export default class ContentMessageView extends Component { | ||
62 | <View style={styles.tabContainer}> | 59 | <View style={styles.tabContainer}> |
63 | {this.props.tabButtons.map((button, index)=> { | 60 | {this.props.tabButtons.map((button, index)=> { |
64 | return <TouchableOpacity style={styles.tabItemContainer} key={index} onPress={()=> { | 61 | return <TouchableOpacity style={styles.tabItemContainer} key={index} onPress={()=> { |
65 | - onPress(button.actionUrl) | 62 | + this.props.onPressTabAction && this.props.onPressTabAction(button.actionUrl, button.type); |
66 | }}> | 63 | }}> |
67 | <ContentMessageTabView icon={button.icon} title={button.description} badge={button.unReadCount}/> | 64 | <ContentMessageTabView icon={button.icon} title={button.description} badge={button.unReadCount}/> |
68 | </TouchableOpacity> | 65 | </TouchableOpacity> |
@@ -73,6 +70,13 @@ export default class ContentMessageView extends Component { | @@ -73,6 +70,13 @@ export default class ContentMessageView extends Component { | ||
73 | ) | 70 | ) |
74 | } | 71 | } |
75 | 72 | ||
73 | + _renderFooter(){ | ||
74 | + return ( | ||
75 | + <View style={[{height: 50}, {backgroundColor: 'white'}, {justifyContent:'center'}]}> | ||
76 | + </View> | ||
77 | + ) | ||
78 | + } | ||
79 | + | ||
76 | render() { | 80 | render() { |
77 | let commentList = this.props.commentList; | 81 | let commentList = this.props.commentList; |
78 | let isPullToRefresh = this.props.isPullToRefresh; | 82 | let isPullToRefresh = this.props.isPullToRefresh; |
@@ -91,6 +95,7 @@ export default class ContentMessageView extends Component { | @@ -91,6 +95,7 @@ export default class ContentMessageView extends Component { | ||
91 | dataSource={this.dataSource.cloneWithRows(commentList)} | 95 | dataSource={this.dataSource.cloneWithRows(commentList)} |
92 | renderRow={this._renderRow} | 96 | renderRow={this._renderRow} |
93 | renderHeader={this._renderHeader} | 97 | renderHeader={this._renderHeader} |
98 | + renderFooter={this._renderFooter} | ||
94 | enableEmptySections={true} | 99 | enableEmptySections={true} |
95 | enablePullToRefresh={true} | 100 | enablePullToRefresh={true} |
96 | isOnPullToRefresh={isPullToRefresh} | 101 | isOnPullToRefresh={isPullToRefresh} |
@@ -112,6 +117,7 @@ export default class ContentMessageView extends Component { | @@ -112,6 +117,7 @@ export default class ContentMessageView extends Component { | ||
112 | dataSource={this.dataSource.cloneWithRows(commentList)} | 117 | dataSource={this.dataSource.cloneWithRows(commentList)} |
113 | renderRow={this._renderRow} | 118 | renderRow={this._renderRow} |
114 | renderHeader={this._renderHeader} | 119 | renderHeader={this._renderHeader} |
120 | + renderFooter={this._renderFooter} | ||
115 | enableEmptySections={true} | 121 | enableEmptySections={true} |
116 | enablePullToRefresh={true} | 122 | enablePullToRefresh={true} |
117 | refreshControl={ | 123 | refreshControl={ |
@@ -57,6 +57,7 @@ class ContentMessageContainer extends Component { | @@ -57,6 +57,7 @@ class ContentMessageContainer extends Component { | ||
57 | this._jumpToShowKeyboard = this._jumpToShowKeyboard.bind(this); | 57 | this._jumpToShowKeyboard = this._jumpToShowKeyboard.bind(this); |
58 | this._jumpToPersonalGrassPage = this._jumpToPersonalGrassPage.bind(this); | 58 | this._jumpToPersonalGrassPage = this._jumpToPersonalGrassPage.bind(this); |
59 | this._jumpToGrassDetailPage = this._jumpToGrassDetailPage.bind(this); | 59 | this._jumpToGrassDetailPage = this._jumpToGrassDetailPage.bind(this); |
60 | + this._onPressTabAction = this._onPressTabAction.bind(this); | ||
60 | } | 61 | } |
61 | 62 | ||
62 | componentDidMount() { | 63 | componentDidMount() { |
@@ -92,6 +93,12 @@ class ContentMessageContainer extends Component { | @@ -92,6 +93,12 @@ class ContentMessageContainer extends Component { | ||
92 | this.props.actions.hiddenTipMessage(); | 93 | this.props.actions.hiddenTipMessage(); |
93 | } | 94 | } |
94 | 95 | ||
96 | + _onPressTabAction(actionUrl, tabType) { | ||
97 | + this.props.actions.clearBadgeNumAction(tabType); | ||
98 | + | ||
99 | + NativeModules.YH_CommonHelper.jumpWithUrl(actionUrl); | ||
100 | + } | ||
101 | + | ||
95 | _jumpToShowKeyboard(dataSource) { | 102 | _jumpToShowKeyboard(dataSource) { |
96 | this.setState({ | 103 | this.setState({ |
97 | dataSource: dataSource, | 104 | dataSource: dataSource, |
@@ -183,6 +190,7 @@ class ContentMessageContainer extends Component { | @@ -183,6 +190,7 @@ class ContentMessageContainer extends Component { | ||
183 | jumpToShowKeyboard={this._jumpToShowKeyboard} | 190 | jumpToShowKeyboard={this._jumpToShowKeyboard} |
184 | jumpToPersonalGrassPage={this._jumpToPersonalGrassPage} | 191 | jumpToPersonalGrassPage={this._jumpToPersonalGrassPage} |
185 | jumpToGrassDetailPage={this._jumpToGrassDetailPage} | 192 | jumpToGrassDetailPage={this._jumpToGrassDetailPage} |
193 | + onPressTabAction={this._onPressTabAction} | ||
186 | /> | 194 | /> |
187 | </View> | 195 | </View> |
188 | ) | 196 | ) |
@@ -37,6 +37,8 @@ const { | @@ -37,6 +37,8 @@ const { | ||
37 | SHOW_REPLY_TIP_MESSAGE, | 37 | SHOW_REPLY_TIP_MESSAGE, |
38 | HIDDEN_REPLY_TIP_MESSAGE, | 38 | HIDDEN_REPLY_TIP_MESSAGE, |
39 | 39 | ||
40 | + CLEAR_BADGE_NUM_SUCCESS, | ||
41 | + | ||
40 | } = require('../../constants/actionTypes').default; | 42 | } = require('../../constants/actionTypes').default; |
41 | 43 | ||
42 | export function setContentListId(id) { | 44 | export function setContentListId(id) { |
@@ -171,6 +173,13 @@ export function hiddenTipMessage() { | @@ -171,6 +173,13 @@ export function hiddenTipMessage() { | ||
171 | } | 173 | } |
172 | } | 174 | } |
173 | 175 | ||
176 | +export function clearBadgeNumAction(tabType) { | ||
177 | + return { | ||
178 | + type:CLEAR_BADGE_NUM_SUCCESS, | ||
179 | + payload: tabType, | ||
180 | + } | ||
181 | +} | ||
182 | + | ||
174 | 183 | ||
175 | /* | 184 | /* |
176 | * 获取通知类型 | 185 | * 获取通知类型 |
@@ -34,6 +34,8 @@ const { | @@ -34,6 +34,8 @@ const { | ||
34 | SHOW_REPLY_TIP_MESSAGE, | 34 | SHOW_REPLY_TIP_MESSAGE, |
35 | HIDDEN_REPLY_TIP_MESSAGE, | 35 | HIDDEN_REPLY_TIP_MESSAGE, |
36 | 36 | ||
37 | + CLEAR_BADGE_NUM_SUCCESS, | ||
38 | + | ||
37 | } = require('../../constants/actionTypes').default; | 39 | } = require('../../constants/actionTypes').default; |
38 | 40 | ||
39 | const initialState = new InitialState; | 41 | const initialState = new InitialState; |
@@ -85,18 +87,6 @@ export default function grassReducer(state=initialState, action) { | @@ -85,18 +87,6 @@ export default function grassReducer(state=initialState, action) { | ||
85 | .setIn([getContentListObject(action.isLatest), 'pageCount'], action.payload.pageCount) | 87 | .setIn([getContentListObject(action.isLatest), 'pageCount'], action.payload.pageCount) |
86 | .setIn([getContentListObject(action.isLatest), 'shouldShowEmpty'], action.payload.shouldShowEmpty) | 88 | .setIn([getContentListObject(action.isLatest), 'shouldShowEmpty'], action.payload.shouldShowEmpty) |
87 | 89 | ||
88 | - if (!action.isLatest) { | ||
89 | - let list = state.contentType.get('list').toJS(); | ||
90 | - return state.setIn(['contentType', 'list'], Immutable.fromJS(list.map((item)=> { | ||
91 | - if (item.type == action.payload.type) { | ||
92 | - return Object.assign({}, item, { | ||
93 | - unReadCount: 0 | ||
94 | - }) | ||
95 | - } | ||
96 | - return item; | ||
97 | - }))) | ||
98 | - } | ||
99 | - | ||
100 | return state; | 90 | return state; |
101 | } | 91 | } |
102 | 92 | ||
@@ -159,6 +149,18 @@ export default function grassReducer(state=initialState, action) { | @@ -159,6 +149,18 @@ export default function grassReducer(state=initialState, action) { | ||
159 | return state.set('tipMessage', ''); | 149 | return state.set('tipMessage', ''); |
160 | } | 150 | } |
161 | 151 | ||
152 | + case CLEAR_BADGE_NUM_SUCCESS: { | ||
153 | + let typeList = state.contentType.get('list').toJS(); | ||
154 | + return state.setIn(['contentType', 'list'], Immutable.fromJS(typeList.map((item)=> { | ||
155 | + if (item.type == action.payload) { | ||
156 | + return Object.assign({}, item, { | ||
157 | + unReadCount: 0 | ||
158 | + }) | ||
159 | + } | ||
160 | + return item; | ||
161 | + }))); | ||
162 | + } | ||
163 | + | ||
162 | } | 164 | } |
163 | return state; | 165 | return state; |
164 | } | 166 | } |
-
Please register or login to post a comment