MomentCommentView.js
3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import React, {Component} from 'react';
import StorageUtil from '../utils/StorageUtil';
import Utils from '../utils/Utils';
import {xnToast} from "../../utils/utils";
import AppService from "../../service/AppService";
import {
Dimensions,
Image,
Modal,
PixelRatio,
StyleSheet,
Text,
TouchableOpacity,
View
} from 'react-native';
const {width, height} = Dimensions.get('window');
export default class MomentCommentView extends Component {
constructor(props) {
super(props);
this.state = {
show: false,
pageX: 0,
pageY: 0,
height: 0
};
StorageUtil.get('username', (error, object) => {
if (!error && object != null) {
this.setState({username: object.username});
}
});
}
render() {
return (
<View style={[styles.modalContainer, {height: this.state.height}]}>
<Modal transparent={true}
visible={this.state.show}
onRequestClose={() => this.closeModal()}>
<TouchableOpacity style={[styles.modalContainer, {height: this.state.height}]}
onPress={() => this.closeModal()}>
<View style={[styles.container, {left: this.state.pageX - 35, top: this.state.pageY - 50}]}>
<TouchableOpacity onPress={() => this.doDelComment()}>
<View style={styles.menuItemContainer}>
<Text style={styles.menuItemText}> 删除 </Text>
</View>
</TouchableOpacity>
</View>
</TouchableOpacity>
</Modal>
</View>
);
}
doDelComment() {
// console.warn("评论"+this.state.momentId);
let callback = this.state.callback;
if (!Utils.isEmpty(callback)) {
callback(this.state.comment, this.state.momentIndex, this.state.commentIndex);
}
this.closeModal();
}
closeModal() {
this.setState({show: false, height: 0});
}
showModal(pageX, pageY, comment, momentIndex, commentIndex, callback) {
//alert(commentId);
this.setState({
pageX: pageX,
pageY: pageY,
height: height,
show: true,
comment: comment,
momentIndex: momentIndex,
commentIndex: commentIndex,
callback: callback,
});
}
}
const styles = StyleSheet.create({
modalContainer: {
width: width,
},
container: {
backgroundColor: '#fff',
borderRadius: 2,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
width: 80,
padding: 5,
height: 35,
position: 'absolute',
left: 230,
top: 500,
borderColor:'#999',
borderWidth:0.3
},
divider: {
width: 1 / PixelRatio.get(),
marginLeft: 20,
marginRight: 20,
height: 25,
backgroundColor: '#DDDDDD'
},
menuItemContainer: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
},
menuItemImg: {
width: 20,
height: 20,
marginTop: 10,
marginBottom: 10,
},
menuItemText: {
color: '#000',
fontSize: 15
}
})