No Description

UserCenterItem.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Created by zack on 2018/6/24.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. Image,
  9. ImageBackground,
  10. TouchableOpacity,
  11. FlatList
  12. } from 'react-native'
  13. import React, {Component} from 'react'
  14. import {NavigationBarHeight, ScreenDimensions} from '../../../utils/DimensionsTools'
  15. export default class UserCenterItem extends Component {
  16. constructor(props) {
  17. super(props)
  18. this.state = {
  19. image: props.image,
  20. title: props.title
  21. }
  22. }
  23. componentWillReceiveProps(props) {
  24. this.setState({
  25. image: props.image,
  26. title: props.title
  27. })
  28. }
  29. shouldComponentUpdate(nextProps) {
  30. if (nextProps.title !== this.state.title) {
  31. return true
  32. }
  33. return false
  34. }
  35. render() {
  36. return (
  37. <View style={styles.View}>
  38. <Image style={styles.ImageView} source={this.state.image}/>
  39. <Text style={styles.Text}>{this.state.title}</Text>
  40. <View style={{position: 'absolute', width: ScreenDimensions.width - 30, height: 0.5, backgroundColor: '#efeff4', left: 30, bottom: 0}} />
  41. </View>
  42. );
  43. }
  44. }
  45. const styles = StyleSheet.create({
  46. View: {
  47. width: ScreenDimensions.width,
  48. height: 50,
  49. backgroundColor: 'white',
  50. flexDirection: 'row',
  51. alignItems: 'center'
  52. },
  53. ImageView: {
  54. marginLeft: 30,
  55. marginRight: 17,
  56. marginTop: 5,
  57. },
  58. Text: {
  59. fontSize: 13,
  60. color: '#666666'
  61. }
  62. })