ScrollRow.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @param:
  3. * itemWidth: 每一个图片宽度
  4. * itemHeight: 每一个图片高度
  5. * data: 数据 Arrary
  6. */
  7. import React, { Component } from "react";
  8. import {
  9. StyleSheet,
  10. Text,
  11. View,
  12. FlatList,
  13. TouchableOpacity,
  14. Image
  15. } from "react-native";
  16. import Dimensions from '../utils/dimensions'
  17. export default class ScrollRow extends Component {
  18. render() {
  19. return (
  20. <FlatList
  21. data={this.props.data}
  22. horizontal={true}
  23. renderItem={({ item, separators }) => this.renderItem(item, separators)}
  24. />
  25. )
  26. }
  27. renderItem(item, separators) {
  28. return (
  29. <TouchableOpacity
  30. style={{
  31. // flex: 1,
  32. height: this.props.itemHeight,
  33. width: this.props.itemWidth,
  34. flexDirection: 'row',
  35. alignItems: 'center',
  36. marginLeft: 9,
  37. }}
  38. onPress={() => {
  39. alert(item.title);
  40. }}
  41. activeOpacity={1}
  42. >
  43. <View style={{
  44. height: this.props.itemHeight,
  45. width: this.props.itemWidth,
  46. flexDirection: 'column',
  47. alignItems: 'center',
  48. // flex: 1,
  49. }}>
  50. <Image
  51. source={{
  52. uri: item.zoneCourse ? item.zoneCourse.iconImg : item.boothContent
  53. // uri: item.icon
  54. }}
  55. style={{
  56. borderRadius: 10,
  57. width: this.props.itemWidth,
  58. height: this.props.itemHeight,
  59. marginBottom: 6,
  60. }}
  61. />
  62. {item.summary
  63. ?
  64. <Text style={styles.itemSummary}>
  65. {item.summary}
  66. </Text>
  67. :
  68. null
  69. }
  70. </View>
  71. </TouchableOpacity>
  72. )
  73. }
  74. }
  75. const styles = StyleSheet.create({
  76. wrapper: {
  77. },
  78. itemSummary: {
  79. // flex:1,
  80. width: '100%',
  81. height: 20,
  82. alignItems: 'center',
  83. justifyContent: "flex-start",
  84. color: '#151515',
  85. fontSize: 13,
  86. }
  87. })