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

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