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 BasePage from '../BasePage'
  17. import Dimensions from '../utils/dimensions'
  18. export default class ScrollRow extends BasePage {
  19. render() {
  20. return (
  21. <FlatList
  22. data={this.props.data}
  23. horizontal={true}
  24. renderItem={({ item, separators }) => this.renderItem(item, separators)}
  25. />
  26. )
  27. }
  28. renderItem(item, separators) {
  29. console.log(this.toNextPage)
  30. return (
  31. <TouchableOpacity
  32. style={{
  33. // flex: 1,
  34. height: this.props.itemHeight,
  35. width: this.props.itemWidth,
  36. flexDirection: 'row',
  37. alignItems: 'center',
  38. marginLeft: 9,
  39. }}
  40. onPress={() => this.toNextPage('SchedulePage')}
  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. })