Comment.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import React, { Component } from "react";
  2. import {
  3. StyleSheet,
  4. Text,
  5. View,
  6. Image,
  7. TextInput,
  8. TouchableOpacity
  9. } from "react-native";
  10. export default class Comment extends Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. text: '',
  15. input: false,
  16. default: '写评论'
  17. };
  18. }
  19. render() {
  20. return (
  21. <View style={styles.courseComment}>
  22. <View style={[styles.padding, styles.title]}>
  23. <Text style={styles.font}>{this.props.title}</Text>
  24. <TouchableOpacity onPress={() => this.comments()}>
  25. <View style={[ styles.button, styles.center ]}>
  26. <Image source={require('../images/courseDetails/comment.png')} style={styles.iconSize} />
  27. <Text>写评论</Text>
  28. </View>
  29. </TouchableOpacity>
  30. </View>
  31. <View style={[ styles.padding ]}>
  32. <View style={[ styles.title ]}>
  33. <View style={[ styles.center ]}>
  34. <Image style={[styles.headImg ]}></Image>
  35. <View>
  36. <Text style={{ fontSize: 16, color: '#373737' }}>小幸运</Text>
  37. <Text style={{ fontSize: 14, color: '#7F7F7F' } }>2019-07-05</Text>
  38. </View>
  39. </View>
  40. <View style={[ styles.center ]}>
  41. <Image source={require('../images/courseDetails/reply.png')} style={styles.reply} />
  42. <Text>回复</Text>
  43. </View>
  44. </View>
  45. <View style={ styles.padding }>
  46. <Text>爱上识字爱上文字的美,了解文字,幽默风趣的画风,动画识字展示让识字更有趣,跟喜欢。</Text>
  47. </View>
  48. <View style={[ styles.padding, styles.column ]}>
  49. <Text style={ styles.color }>卡通小熊</Text>
  50. <Text>爱上识字爱上文字的美,了解文字,幽默风趣的画风,动画识字展示让识字更有趣,跟喜欢。</Text>
  51. </View>
  52. </View>
  53. {
  54. this.state.input ?
  55. <View style={[ styles.input, this.state.fullStyle]}>
  56. <TextInput
  57. style={{height: '100%', borderColor: '#DFDFDF', borderWidth: 1, width: '90%', backgroundColor: '#fff', borderRadius: 6, padding: 0, textAlignVertical: 'top', padding: 10}}
  58. onChangeText={(text) => this.setState({text})}
  59. value={this.state.text}
  60. numberOfLines={7}
  61. multiline = {true}
  62. autoFocus = {true}
  63. defaultValue= {this.state.default}
  64. />
  65. <Text style={{ color: '#58A8FA', fontSize: 18}}>发送</Text>
  66. </View>
  67. :
  68. null
  69. }
  70. </View>
  71. );
  72. }
  73. comments() {
  74. this.setState({
  75. input: true
  76. })
  77. }
  78. }
  79. const styles = StyleSheet.create({
  80. courseComment: {
  81. width: '100%',
  82. backgroundColor: '#fff',
  83. marginTop: 8,
  84. marginBottom: 60
  85. },
  86. padding: {
  87. paddingLeft: 20,
  88. paddingRight: 20,
  89. paddingTop: 10,
  90. paddingBottom: 10,
  91. },
  92. title: {
  93. display: 'flex',
  94. flexDirection: 'row',
  95. justifyContent: 'space-between',
  96. alignItems: 'center',
  97. },
  98. font: {
  99. fontSize: 24,
  100. color: 'black',
  101. fontWeight: 'bold',
  102. },
  103. center: {
  104. display: 'flex',
  105. flexDirection: 'row',
  106. alignItems: 'center',
  107. justifyContent: 'center',
  108. },
  109. button: {
  110. width: 98,
  111. height: 28,
  112. fontSize: 20,
  113. borderRadius: 28,
  114. color: 'black',
  115. backgroundColor: '#F0F1F5'
  116. },
  117. headImg: {
  118. width: 40,
  119. height: 40,
  120. backgroundColor: "red",
  121. marginRight: 10,
  122. borderRadius: 40
  123. },
  124. iconSize: {
  125. width: 20,
  126. height: 20,
  127. marginRight: 10
  128. },
  129. reply: {
  130. width: 16,
  131. height: 15,
  132. marginRight: 5
  133. },
  134. courseFont: {
  135. color: '#373737',
  136. fontSize: 16
  137. },
  138. column: {
  139. display: 'flex',
  140. flexDirection: 'column',
  141. backgroundColor: '#F3F6FF'
  142. },
  143. color: {
  144. color: '#518AD1'
  145. },
  146. input: {
  147. width: '100%',
  148. height: 124,
  149. backgroundColor: '#F9F9F9',
  150. paddingLeft: 18,
  151. paddingTop: 18,
  152. paddingBottom: 18,
  153. paddingRight: 24,
  154. display: 'flex',
  155. flexDirection: 'row',
  156. justifyContent: 'space-between',
  157. alignItems: 'flex-end'
  158. }
  159. });