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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. marginBottom: 5,
  29. }}
  30. key={index.toString()}
  31. />;
  32. };
  33. render() {
  34. if (this.props.items.length > 0) {
  35. return (
  36. <View style={this.props.style}>
  37. {this.getGrids()}
  38. </View>
  39. );
  40. } else
  41. return null;
  42. }
  43. }
  44. export default withTheme(Preview);