diff --git a/src/component/notification/notification.js b/src/component/notification/notification.js index a6970cd..619bbde 100644 --- a/src/component/notification/notification.js +++ b/src/component/notification/notification.js @@ -2,21 +2,11 @@ import React, {Component} from 'react'; import {Image, StyleSheet, Text, View, TouchableOpacity} from 'react-native'; import Ionicons from 'react-native-vector-icons/Ionicons'; +import UserIcon from '../userIcon'; import Touchable from '../touchable'; import Color from '../../style/color'; -function unique(array) { - let n = []; - for(let i=0; i it.content.author.name)).join('、'); - const body = `${users} 回复了你`; + const max = 5; + const formatMsg = {}; + + let key = null; + for (let i=0; i this.props.onCommentPress(msg)}> - {body} + { + Object.keys(formatMsg).map((it, index) => { + if (index >= max) { + return null; + } + + return ( + this.props.onUserIconPress(formatMsg[it])} + /> + ); + }) + } + + {Object.keys(formatMsg).length > max ? '等' : ''}回复了你 + {this.renderDeleteButton(msg)} @@ -76,7 +95,11 @@ export default class Notification extends Component { } renderLike(msg) { - const body = `${msg.content.user.name} 给了你一个OK绷`; + const userData = { + userId: msg.content.user.id, + userIcon: msg.link_user_icon, + userName: msg.content.user.name, + } return ( this.props.onLikePress(msg)}> @@ -88,7 +111,12 @@ export default class Notification extends Component { } style={localStyle.icon2} /> - {body} + this.props.onUserIconPress(userData)} + /> + 给了你一个OK绷 {this.renderDeleteButton(msg)} @@ -108,17 +136,17 @@ const localStyle = StyleSheet.create({ icon: { marginRight: 10, marginTop: 1, - lineHeight: 20 + lineHeight: 28 }, text: { flex: 1, - lineHeight: 20 + lineHeight: 28 }, icon2: { width: 15, height: 15, marginRight: 10, - marginTop: 4, + marginTop: 7, }, delete: { lineHeight: 20, diff --git a/src/component/notification/notificationList.js b/src/component/notification/notificationList.js index bec7903..74cb574 100644 --- a/src/component/notification/notificationList.js +++ b/src/component/notification/notificationList.js @@ -107,6 +107,29 @@ export default class NotificationList extends Component { } } + _onUserIconPress(msg) { + Navigation.push(this.props.componentId, { + component: { + name: 'User', + options: { + bottomTabs: { + visible: false, + + // hide bottom tab for android + drawBehind: true, + animate: true + } + }, + passProps: { + user: { + id: msg.userId, + name: msg.userName, + } + } + } + }); + } + _onCommentPress(msg) { Navigation.push(this.props.componentId, { component: { @@ -160,7 +183,7 @@ export default class NotificationList extends Component { _onLikePress(msg) { Navigation.push(this.props.componentId, { component: { - name: 'User', + name: 'DiaryDetail', options: { bottomTabs: { visible: false, @@ -171,7 +194,7 @@ export default class NotificationList extends Component { } }, passProps: { - user: msg.content.user + diaryId: msg.content.dairy_id } } }); @@ -200,11 +223,12 @@ export default class NotificationList extends Component { renderItem={({item}) => { return ( ); }} diff --git a/src/component/userIcon.js b/src/component/userIcon.js index feb6a69..7753a9a 100644 --- a/src/component/userIcon.js +++ b/src/component/userIcon.js @@ -24,8 +24,7 @@ export default class UserIcon extends Component { render() { return ( - r1 !== r2 - // }); - // this.state = ({ - // messages: [], - // messagesDataSource: ds, - // refreshing: true, - // }); } navigationButtonPressed({buttonId}) {