Image.js 907 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. export default class ImageComp extends Module {
  6. constructor(props) {
  7. super(props);
  8. }
  9. display() {
  10. let {
  11. width,
  12. height,
  13. resizeMode,
  14. source
  15. } = this.props;
  16. if(!width) width = ImageComp.Inputs.width.default || 100;
  17. if(!height) height = ImageComp.Inputs.height.default || 100;
  18. if(!resizeMode) resizeMode = ImageComp.Inputs.resizeMode.default || 'cover';
  19. return <Image
  20. style={{width, height}}
  21. resizeMode={resizeMode}
  22. source={source || require('./assets/default.jpg')}
  23. />
  24. }
  25. }
  26. ImageComp.Inputs = {
  27. source: new Types.Text(),
  28. width: new Types.Integer().require().default(100),
  29. height: new Types.Integer().require().default(100),
  30. resizeMode: new Types.Text().require().default('cover')
  31. }