3
0

index.js 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. borderRadius
  18. } = this.props;
  19. console.log(width);
  20. if(!width) width = "100%";
  21. return <Image
  22. style={{borderRadius,width, height, paddingTop: height ? '0' : '56.25%'}}
  23. resizeMode={resizeMode}
  24. source={source || image}
  25. />
  26. }
  27. }
  28. ImageComp.Inputs = {
  29. source: new Types.Text(),
  30. width: new Types.Integer(),
  31. height: new Types.Integer(),
  32. resizeMode: new Types.Text().require().default('cover'),
  33. borderRadius: new Types.Integer()
  34. }