Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Preview.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // @flow
  2. import * as React from 'react';
  3. import {View} from 'react-native';
  4. import {withTheme} from 'react-native-paper';
  5. import type {Grid} from "./GridComponent";
  6. import GridComponent from "./GridComponent";
  7. import type {ViewStyle} from "react-native/Libraries/StyleSheet/StyleSheet";
  8. type Props = {
  9. items: Array<Grid>,
  10. style: ViewStyle
  11. }
  12. class Preview extends React.PureComponent<Props> {
  13. getGrids() {
  14. let grids = [];
  15. for (let i = 0; i < this.props.items.length; i++) {
  16. grids.push(this.getGridRender(this.props.items[i], i));
  17. }
  18. return grids;
  19. }
  20. getGridRender(item: Grid, index: number) {
  21. return <GridComponent
  22. width={item[0].length}
  23. height={item.length}
  24. grid={item}
  25. style={{
  26. marginRight: 5,
  27. marginLeft: 5,
  28. }}
  29. key={index.toString()}
  30. />;
  31. };
  32. render() {
  33. if (this.props.items.length > 0) {
  34. return (
  35. <View style={this.props.style}>
  36. {this.getGrids()}
  37. </View>
  38. );
  39. } else
  40. return null;
  41. }
  42. }
  43. export default withTheme(Preview);