3
0

index.js 878 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. if(!width) width = "100%";
  20. return <Image
  21. style={{borderRadius, 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. borderRadius: new Types.Integer()
  33. }