No Description

MineTextItem.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Created by zack on 2018/6/23.
  3. */
  4. /**
  5. * Created by zack on 2018/6/23.
  6. */
  7. import {
  8. View,
  9. Text,
  10. StyleSheet,
  11. Image,
  12. ImageBackground,
  13. TouchableOpacity,
  14. FlatList
  15. } from 'react-native'
  16. import React, {Component} from 'react'
  17. import {NavigationBarHeight, ScreenDimensions} from '../../../utils/DimensionsTools'
  18. export default class MineTextItem extends Component {
  19. constructor(props) {
  20. super(props)
  21. this.state = {
  22. title: props.title,
  23. desc: props.desc
  24. }
  25. }
  26. componentWillReceiveProps(props) {
  27. this.setState({
  28. title: props.title,
  29. desc: props.desc
  30. })
  31. }
  32. shouldComponentUpdate(nextProps) {
  33. if (nextProps.title !== this.state.title || nextProps.desc !== this.state.desc) {
  34. return true
  35. }
  36. return false
  37. }
  38. render() {
  39. return(
  40. <TouchableOpacity onPress={() => {
  41. this.props.didSelectedItem()
  42. }} style={styles.View}>
  43. <Text style={styles.LeftText}>{this.state.title}</Text>
  44. <View style={styles.ContainerView}>
  45. <Text numberOfLines={1} style={styles.DescText}>{this.state.desc}</Text>
  46. <Image source={require('../../../resources/images/Mine/Right-Arrow.png')}/>
  47. </View>
  48. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  49. </TouchableOpacity>
  50. )
  51. }
  52. }
  53. const styles = StyleSheet.create({
  54. View: {
  55. width: ScreenDimensions.width,
  56. height: 80,
  57. backgroundColor: 'white',
  58. flexDirection: 'row',
  59. alignItems: 'center',
  60. justifyContent: 'space-between',
  61. },
  62. LeftText: {
  63. fontSize: 14,
  64. color: '#333333',
  65. marginLeft: 15,
  66. },
  67. ContainerView: {
  68. marginRight: 15,
  69. flexDirection: 'row',
  70. alignItems: 'center',
  71. justifyContent: 'center'
  72. },
  73. DescText: {
  74. fontSize: 14,
  75. color: '#333333',
  76. marginRight: 12,
  77. width: ScreenDimensions.width - 180,
  78. textAlign: 'right'
  79. }
  80. })