No Description

AnswerQuestionCommentItem.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. import {
  2. View,
  3. Text,
  4. StyleSheet,
  5. Image,
  6. ImageBackground,
  7. TouchableOpacity,
  8. FlatList
  9. } from 'react-native'
  10. import React, {Component} from 'react'
  11. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../../utils/DimensionsTools'
  12. export default class AnswerQuestionCommentItem extends Component {
  13. constructor(props) {
  14. super(props)
  15. this.state = {
  16. headerImageUrl: props.headerImageUrl,
  17. likes: props.likes,
  18. shares: props.shares,
  19. commentCount: props.commentCount,
  20. userName: props.userName,
  21. commentContent: props.commentContent,
  22. read: props.read
  23. }
  24. }
  25. componentWillReceiveProps(props) {
  26. this.setState({
  27. headerImageUrl: props.headerImageUrl,
  28. likes: props.likes,
  29. shares: props.shares,
  30. commentCount: props.commentCount,
  31. userName: props.userName,
  32. commentContent: props.commentContent,
  33. read: props.read
  34. })
  35. }
  36. shouldComponentUpdate(nextProps) {
  37. if (nextProps.headerImageUrl !== this.state.headerImageUrl ||
  38. nextProps.likes !== this.state.likes ||
  39. nextProps.shares !== this.state.shares ||
  40. nextProps.commentCount !== this.state.commentCount ||
  41. nextProps.userName !== this.state.userName ||
  42. nextProps.commentContent !== this.state.commentContent ||
  43. nextProps.read !== this.state.read
  44. ) {
  45. return true
  46. }
  47. return false
  48. }
  49. render() {
  50. return(
  51. <View style={styles.View}>
  52. <View style={styles.UserInfoBgView}>
  53. <ImageBackground source={require('../../../../resources/images/TabBar/Community/Answer/user.png')} style={styles.UserHeaderImageView}>
  54. {/*<Image style={styles.UserHeaderTagImageView}/>*/}
  55. </ImageBackground>
  56. <Text style={styles.UserName}>{this.state.userName}</Text>
  57. </View>
  58. <Text style={styles.TitleText}>{this.state.commentContent}</Text>
  59. <Text style={styles.ReadNumberText}>{this.state.read + '阅读'}</Text>
  60. <View style = {styles.BottomTagBgView}>
  61. <View style={styles.BottomLineView} />
  62. <TouchableOpacity onPress={() => {
  63. this.props.clickItemBottomButton(0)
  64. }} style={styles.BottomButtonView}>
  65. <Image source={require('../../../../resources/images/TabBar/Community/Answer/like.png')} style={[styles.BottomButtonImageView, {marginLeft: 48}]}/>
  66. <Text style={styles.BottomButtonText}>{this.state.likes}</Text>
  67. </TouchableOpacity>
  68. <TouchableOpacity style={styles.BottomButtonView}>
  69. <Image source={require('../../../../resources/images/TabBar/Community/Answer/mess.png')} style={styles.BottomButtonImageView}/>
  70. <Text style={styles.BottomButtonText}>{this.state.commentCount}</Text>
  71. </TouchableOpacity>
  72. <TouchableOpacity style={styles.BottomButtonView}>
  73. <Image source={require('../../../../resources/images/TabBar/Community/Answer/Forward.png')} style={[styles.BottomButtonImageView]}/>
  74. <Text style={[styles.BottomButtonText, {marginRight: 48}]}>{this.state.shares}</Text>
  75. </TouchableOpacity>
  76. </View>
  77. </View>
  78. )
  79. }
  80. }
  81. const styles = StyleSheet.create({
  82. View: {
  83. width: ScreenDimensions.width,
  84. backgroundColor: 'white',
  85. },
  86. UserInfoBgView: {
  87. marginTop: 13,
  88. width: ScreenDimensions.width,
  89. flexDirection: 'row',
  90. alignItems: 'center',
  91. },
  92. UserHeaderImageView: {
  93. width: 48,
  94. height: 48,
  95. borderRadius: 24,
  96. backgroundColor: 'red',
  97. marginLeft: 24,
  98. },
  99. UserHeaderTagImageView: {
  100. height: 9,
  101. width: 9,
  102. backgroundColor: 'blue',
  103. position: 'absolute',
  104. bottom: 0,
  105. right: 0,
  106. },
  107. UserName: {
  108. fontSize: 15,
  109. color: '#505050',
  110. marginLeft: 27
  111. },
  112. TitleText: {
  113. fontSize: 15,
  114. color: '#000000',
  115. marginLeft: 24,
  116. marginTop: 14,
  117. },
  118. ReadNumberText: {
  119. fontSize: 15,
  120. color: '#9c9c9c',
  121. marginLeft: 24,
  122. marginTop: 20,
  123. },
  124. BottomTagBgView: {
  125. marginTop: 24,
  126. width: ScreenDimensions.width,
  127. height: 56,
  128. backgroundColor: '#eef0ef',
  129. flexDirection: 'row',
  130. },
  131. BottomButtonView: {
  132. width: ScreenDimensions.width/3.0,
  133. height: 48,
  134. flexDirection: 'row',
  135. justifyContent: 'center',
  136. alignItems: 'center',
  137. backgroundColor: 'white'
  138. },
  139. BottomButtonImageView: {
  140. marginRight: 13,
  141. },
  142. BottomButtonText: {
  143. fontSize: 13,
  144. color: '#9c9c9c'
  145. },
  146. BottomLineView: {
  147. position: 'absolute',
  148. width: ScreenDimensions.width,
  149. height: 0.5,
  150. backgroundColor: '#d7d7d7',
  151. left: 0,
  152. top: 0,
  153. },
  154. })