ScrollRow.js 2.6 KB

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