Brak opisu

TranslationView.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /**
  2. * Created by zack on 2018/4/27.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. TouchableOpacity,
  9. Image,
  10. TextInput,
  11. Keyboard,
  12. ScrollView
  13. } from 'react-native'
  14. import React, {Component} from 'react'
  15. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../utils/DimensionsTools'
  16. export default class TranslationView extends Component {
  17. constructor(props) {
  18. super(props)
  19. this.state = {
  20. evaluationSelectedIndex: 0,
  21. isVerified: props.isVerified,
  22. isShowAnswer: false
  23. }
  24. }
  25. componentWillReceiveProps(props) {
  26. this.setState({isVerified: props.isVerified})
  27. }
  28. renderAnswer(isShow) {
  29. if (isShow) {
  30. return(
  31. <View style={{borderBottomRightRadius: 6, borderBottomLeftRadius: 6}}>
  32. <Text style={styles.AnswerText}>{"Picasso once said this, he said that all children are born artists. The problem is to remain an artist as we grow up. "}</Text>
  33. </View>
  34. )
  35. }else {
  36. return(
  37. <TouchableOpacity onPress={() => {
  38. this.setState({isShowAnswer: true})
  39. }}>
  40. <Text style={styles.AnswerButtonText}>{'点击查看答案'}</Text>
  41. </TouchableOpacity>
  42. )
  43. }
  44. }
  45. render() {
  46. return(
  47. <ScrollView style= {styles.View}>
  48. <View style={styles.ContainerView}>
  49. <View style={styles.TitleTextBgView}>
  50. <TouchableOpacity style = {styles.VoiceIconButton}>
  51. <Image style={styles.VoiceImageView} source={require('../../../resources/images/TabBar/Learn/btn_speaker.png')}/>
  52. </TouchableOpacity>
  53. <Text style={styles.TitleText}>{"Picasso once said this, he said that all children are born artists. The problem is to remain an artist as we grow up. "}</Text>
  54. </View>
  55. <View style={styles.TextInputBgView}>
  56. <TextInput placeholder={'请翻译成中文'} placeholderTextColor={'#999999'} multiline={true} style={styles.TextInput}/>
  57. </View>
  58. {this.renderAnswer(this.state.isShowAnswer)}
  59. <View style={styles.EvaluationBgView}>
  60. <Text style={styles.EvaluationButtonText}>{'自我感觉:'}</Text>
  61. <TouchableOpacity onPress={() => {
  62. this.setState({
  63. evaluationSelectedIndex: 0
  64. })
  65. }} style={styles.EvaluationButton}>
  66. <Image source={this.state.evaluationSelectedIndex === 0 ? require('../../../resources/images/TabBar/Learn/btn_correct.png') : require('../../../resources/images/TabBar/Learn/btn_normal.png')} style={[styles.EvaluationButtonImageView, {marginLeft: 10}]}/>
  67. <Text style={[styles.EvaluationButtonText, {marginLeft: 10}]}>{'好'}</Text>
  68. </TouchableOpacity>
  69. <TouchableOpacity onPress={() => {
  70. this.setState({
  71. evaluationSelectedIndex: 1
  72. })
  73. }} style={styles.EvaluationButton}>
  74. <Image source={this.state.evaluationSelectedIndex === 1 ? require('../../../resources/images/TabBar/Learn/btn_seleted.png') : require('../../../resources/images/TabBar/Learn/btn_normal.png')} style={[styles.EvaluationButtonImageView, {marginLeft: 44}]}/>
  75. <Text style={[styles.EvaluationButtonText, {marginLeft: 10}]}>{'不好'}</Text>
  76. </TouchableOpacity>
  77. </View>
  78. </View>
  79. <View style={styles.FooterView} />
  80. </ScrollView>
  81. )
  82. }
  83. }
  84. const styles = StyleSheet.create({
  85. View: {
  86. width: ScreenDimensions.width,
  87. height: ScreenDimensions.height - NavigationBarHeight.height - TabBarHeight.height - 18,
  88. marginTop: NavigationBarHeight.height
  89. },
  90. ContainerView: {
  91. alignItems: 'center'
  92. },
  93. TitleTextBgView: {
  94. marginTop: 15,
  95. flexDirection: 'row',
  96. width: ScreenDimensions.width,
  97. },
  98. VoiceIconButton: {
  99. width: 30,
  100. height: 30,
  101. marginLeft: 15,
  102. },
  103. VoiceIconImageView: {
  104. width: 30,
  105. height: 30,
  106. },
  107. TitleText: {
  108. marginLeft: 10,
  109. fontSize: 18,
  110. color: '#333333',
  111. width: ScreenDimensions.width - 40 - 10 - 30,
  112. },
  113. TextInputBgView: {
  114. marginTop: 30,
  115. width: ScreenDimensions.width - 30,
  116. height: 165,
  117. backgroundColor: '#e5e5e5',
  118. borderTopLeftRadius: 6,
  119. borderTopRightRadius: 6,
  120. },
  121. TextInput: {
  122. width: ScreenDimensions.width - 30,
  123. height: 165,
  124. textAlignVertical: 'top',
  125. fontSize: 16,
  126. paddingLeft: 12,
  127. paddingTop: 12,
  128. paddingRight: 12,
  129. paddingBottom: 12
  130. },
  131. AnswerButtonText: {
  132. marginTop: 30,
  133. fontSize: 18,
  134. color: '#666666',
  135. marginBottom: 56,
  136. },
  137. AnswerText: {
  138. marginTop: 0,
  139. marginBottom: 25,
  140. width: ScreenDimensions.width - 30,
  141. height: (ScreenDimensions.height - NavigationBarHeight.height - TabBarHeight.height - 76 - 160)/2.0,
  142. backgroundColor: '#efffe3',
  143. fontSize: 16,
  144. paddingLeft: 10,
  145. paddingTop:10,
  146. paddingRight:10,
  147. paddingBottom: 10,
  148. color: '#666666'
  149. },
  150. EvaluationBgView: {
  151. flexDirection: 'row',
  152. alignItems: 'center',
  153. },
  154. EvaluationButton: {
  155. flexDirection: 'row',
  156. alignItems: 'center',
  157. },
  158. EvaluationButtonImageView: {
  159. width: 22,
  160. height: 22,
  161. },
  162. EvaluationButtonText: {
  163. fontSize: 18,
  164. color: '#666666'
  165. },
  166. FooterView: {
  167. width: ScreenDimensions.width,
  168. height: 44,
  169. backgroundColor: '#ffffff'
  170. }
  171. })