ScrollRow.js 2.7 KB

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