No Description

MineHeaderImageItem.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * Created by zack on 2018/6/23.
  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 MineHeaderImageItem extends Component {
  16. constructor(props) {
  17. super(props)
  18. this.state = {
  19. avatar: props.avatar
  20. }
  21. }
  22. componentWillReceiveProps(props) {
  23. this.setState({
  24. avatar: props.avatar
  25. })
  26. }
  27. shouldComponentUpdate(nextProps) {
  28. if (nextProps.avatar !== this.state.avatar) {
  29. return true
  30. }
  31. return false
  32. }
  33. render() {
  34. return(
  35. <TouchableOpacity onPress={() => {
  36. this.props.didSelectedItem()
  37. }} style={styles.View}>
  38. <Text style={styles.LeftText}>{'头像'}</Text>
  39. <View style={styles.ContainerView}>
  40. <Image style={styles.HeaderImageView} source={require('../../../resources/images/Mine/user.png')}/>
  41. <Image source={require('../../../resources/images/Mine/Right-Arrow.png')}/>
  42. </View>
  43. <View style={{position: 'absolute', width: ScreenDimensions.width, height: 0.5, backgroundColor: '#efeff4', left: 0, bottom: 0}} />
  44. </TouchableOpacity>
  45. )
  46. }
  47. }
  48. const styles = StyleSheet.create({
  49. View: {
  50. width: ScreenDimensions.width,
  51. height: 80,
  52. backgroundColor: '#f7f7f7',
  53. flexDirection: 'row',
  54. alignItems: 'center',
  55. justifyContent: 'space-between',
  56. },
  57. LeftText: {
  58. fontSize: 14,
  59. color: '#333333',
  60. marginLeft: 15,
  61. },
  62. ContainerView: {
  63. marginRight: 15,
  64. flexDirection: 'row',
  65. alignItems: 'center',
  66. justifyContent: 'center'
  67. },
  68. HeaderImageView: {
  69. width: 52,
  70. height: 52,
  71. borderRadius: 5,
  72. marginRight: 12,
  73. },
  74. })