No Description

PicAndTextDetailHeaderItem.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * Created by zack on 2018/5/22.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. FlatList,
  9. Platform,
  10. TouchableOpacity,
  11. Image
  12. } from 'react-native'
  13. import React, {Component} from 'react'
  14. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../../../utils/DimensionsTools'
  15. import ImageLoader from 'react-native-smart-image-loader'
  16. export default class PicAndTextDetailHeaderItem extends Component {
  17. constructor(props) {
  18. super(props)
  19. this.state = {
  20. imageUrls: props.imageUrls,
  21. title: props.title,
  22. }
  23. }
  24. // componentWillReceiveProps(props) {
  25. // this.setState({
  26. // imageUrls: props.imageUrls,
  27. // title: props.title,
  28. // })
  29. // }
  30. //
  31. // shouldComponentUpdate(nextProps) {
  32. // if (nextProps.imageUrls !== this.state.imageUrls ||
  33. // nextProps.title !== this.state.title
  34. // ) {
  35. // return true
  36. // }
  37. //
  38. // return false
  39. // }
  40. renderImageViews() {
  41. let imageViews = []
  42. for (let i = 0; i < this.state.imageUrls.length; i ++) {
  43. let imageLoader = (
  44. <ImageLoader
  45. key = {i}
  46. style={[styles.ImageView, {marginBottom: (i < 3 ? 8 : 0), marginRight: (i > 0 && (i+ 1)%3 === 0) ? 0 : 8}]}
  47. options={{
  48. src: this.state.imageUrls[i],
  49. }}
  50. />)
  51. imageViews.push(imageLoader)
  52. }
  53. return imageViews
  54. }
  55. render() {
  56. return(
  57. <View style={styles.View}>
  58. <Text style={styles.TimeText}>{'15分钟前'}</Text>
  59. <Text style={styles.TitleText}>{this.state.title}</Text>
  60. <TouchableOpacity onPress={() => {
  61. this.props.didClickImageViewContainer()
  62. }} style={styles.ImageContainerView}>
  63. {this.renderImageViews()}
  64. </TouchableOpacity>
  65. <View style={styles.BottomLineView}/>
  66. </View>
  67. )
  68. }
  69. }
  70. const styles = StyleSheet.create({
  71. View: {
  72. width: ScreenDimensions.width,
  73. backgroundColor: 'white'
  74. },
  75. TimeText: {
  76. fontSize: 13,
  77. color: '#6c6c6c',
  78. marginTop: 13,
  79. marginLeft: 23,
  80. },
  81. TitleText: {
  82. fontSize: 16,
  83. color: '#05120b',
  84. marginTop: 13,
  85. marginLeft: 23,
  86. },
  87. ImageContainerView: {
  88. marginTop: 17,
  89. width: ScreenDimensions.width - 30,
  90. marginLeft: 15,
  91. flexDirection: 'row',
  92. flexWrap: 'wrap',
  93. marginBottom: 10,
  94. },
  95. ImageView: {
  96. width: (ScreenDimensions.width - 30 - 16)/3.0,
  97. height: (ScreenDimensions.width - 30 - 16)/3.0,
  98. },
  99. BottomLineView: {
  100. width: ScreenDimensions.width,
  101. height: 8,
  102. backgroundColor: '#efeff4'
  103. }
  104. })