ScrollRow.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. keyExtractor={(item, index) => index.toString()}
  27. />
  28. )
  29. }
  30. renderItem(item, separators) {
  31. console.log(this.toNextPage)
  32. const courseId = item.course ? item.course.id : item.operationContent;
  33. return (
  34. <TouchableOpacity
  35. style={{
  36. // flex: 1,
  37. height: this.props.itemHeight,
  38. width: this.props.itemWidth,
  39. flexDirection: 'row',
  40. alignItems: 'center',
  41. marginLeft: 9,
  42. }}
  43. onPress={() => this.props.nav('CourseDetails', {courseId})}
  44. activeOpacity={1}
  45. >
  46. <View style={{
  47. height: this.props.itemHeight,
  48. width: this.props.itemWidth,
  49. flexDirection: 'column',
  50. alignItems: 'center',
  51. // flex: 1,
  52. }}>
  53. <Image
  54. source={{
  55. uri: item.zoneCourse ? item.zoneCourse.iconImg : item.boothContent
  56. // uri: item.icon
  57. }}
  58. style={{
  59. borderRadius: 10,
  60. width: this.props.itemWidth,
  61. height: this.props.itemHeight,
  62. marginBottom: 6,
  63. }}
  64. />
  65. {item.summary
  66. ?
  67. <Text style={styles.itemSummary}>
  68. {item.summary}
  69. </Text>
  70. :
  71. null
  72. }
  73. </View>
  74. </TouchableOpacity>
  75. )
  76. }
  77. }
  78. const styles = StyleSheet.create({
  79. wrapper: {
  80. },
  81. itemSummary: {
  82. // flex:1,
  83. width: '100%',
  84. height: 20,
  85. alignItems: 'center',
  86. justifyContent: "flex-start",
  87. color: '#151515',
  88. fontSize: 13,
  89. }
  90. })