3
0

index.js 830 B

123456789101112131415161718192021222324252627282930313233343536
  1. import React from 'react';
  2. import Types from '../../lib/Types';
  3. import Module from '../../lib/Module';
  4. import { View, Image } from 'react-native';
  5. let image = require('./assets/default.jpg')
  6. export default class ImageComp extends Module {
  7. constructor(props) {
  8. super(props);
  9. this.setContainerStyle({ marginLeft: 0, marginRight: 0});
  10. }
  11. display() {
  12. let {
  13. width,
  14. height,
  15. resizeMode,
  16. source
  17. } = this.props;
  18. console.log(width);
  19. if(!width) width = "100%";
  20. return <Image
  21. style={{width, height, paddingTop: height ? '0' : '56.25%'}}
  22. resizeMode={resizeMode}
  23. source={source || image}
  24. />
  25. }
  26. }
  27. ImageComp.Inputs = {
  28. source: new Types.Text(),
  29. width: new Types.Integer(),
  30. height: new Types.Integer(),
  31. resizeMode: new Types.Text().require().default('cover')
  32. }