ScrollRow.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * @param:
  3. * width: 每一个item宽度
  4. * height: 每一个item高度
  5. * data: 数据 Arrary
  6. */
  7. import React, { Component } from "react";
  8. import {
  9. StyleSheet,
  10. Text,
  11. View,
  12. } from "react-native";
  13. import Dimensions from '../utils/dimensions'
  14. const styles = StyleSheet.create({
  15. })
  16. export default class ScrollRow extends Component {
  17. render() {
  18. return (
  19. <FlatList
  20. data={[{ title: 'Title Text', key: 'item1' }]}
  21. horizontal={true}
  22. renderItem={({ item, separators }) => (
  23. <TouchableOpacity
  24. style={{
  25. flex: 1,
  26. height: "100%",
  27. width: this.getWindowWidth() * 0.9
  28. }}
  29. onPress={() => {
  30. alert(item.name);
  31. }}
  32. activeOpacity={1}
  33. >
  34. <Image
  35. source={{
  36. uri: item.icon
  37. }}
  38. style={{
  39. height: "100%",
  40. width: "100%",
  41. justifyContent: "center",
  42. alignItems: "center",
  43. borderRadius: 20
  44. }}
  45. />
  46. </TouchableOpacity>
  47. )}
  48. />
  49. )
  50. }
  51. }