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}
+ />
);
}}