From b22c1b454db194ee20567e49fb7bc0a1369854e9 Mon Sep 17 00:00:00 2001 From: mx1700 Date: Sun, 28 Jul 2019 20:50:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E9=86=92=E5=A2=9E=E5=8A=A0=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/notification/notification.js | 23 ++++++++++++++++++- .../notification/notificationList.js | 14 ++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/component/notification/notification.js b/src/component/notification/notification.js index 4b4f028..70d3898 100644 --- a/src/component/notification/notification.js +++ b/src/component/notification/notification.js @@ -1,5 +1,5 @@ import React, {Component} from 'react'; -import {Image, StyleSheet, Text, View} from 'react-native'; +import {Image, StyleSheet, Text, View, TouchableOpacity} from 'react-native'; import Ionicons from 'react-native-vector-icons/Ionicons'; import Touchable from '../touchable'; @@ -19,6 +19,10 @@ function unique(array) { export default class Notification extends Component { + _onDeletePress(msg) { + this.props.onDeletePress && this.props.onDeletePress(msg) + } + render() { let msg = this.props.msg; if(msg && msg.type) { @@ -35,6 +39,14 @@ export default class Notification extends Component { return null; } + renderDeleteButton(msg) { + return this.props.showDelete ? ( + this._onDeletePress(msg)}> + + + ) : null; + } + renderComment(msg) { const users = unique(msg.list.map(it => it.content.author.name)).join('、'); const body = `${users} 回复了你`; @@ -44,6 +56,7 @@ export default class Notification extends Component { {body} + {this.renderDeleteButton(msg)} ) @@ -57,6 +70,7 @@ export default class Notification extends Component { {body} + {this.renderDeleteButton(msg)} ) @@ -76,10 +90,13 @@ export default class Notification extends Component { style={localStyle.icon2} /> {body} + {this.renderDeleteButton(msg)} ) } + + } const localStyle = StyleSheet.create({ @@ -104,4 +121,8 @@ const localStyle = StyleSheet.create({ marginRight: 10, marginTop: 4, }, + delete: { + lineHeight: 20, + paddingHorizontal: 8, + } }); \ No newline at end of file diff --git a/src/component/notification/notificationList.js b/src/component/notification/notificationList.js index 77bc808..fd45e8e 100644 --- a/src/component/notification/notificationList.js +++ b/src/component/notification/notificationList.js @@ -179,6 +179,12 @@ export default class NotificationList extends Component { } } + _onDeletePress(msg) { + if(this.props.isSetRead) { + this._setRead(msg); + } + } + render() { let hasData = this.state.notifications && this.state.notifications.length > 0; return hasData ? ( @@ -192,10 +198,12 @@ export default class NotificationList extends Component { renderItem={({item}) => { return ( + onDeletePress={this._onDeletePress.bind(this)} + showDelete={this.props.isSetRead} + /> ); }}