Module.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React, {Fragment} from 'react';
  2. import { View } from 'react-native';
  3. import { Resolver } from './Types';
  4. // EventSystem
  5. export default class Module extends React.Component{
  6. constructor(props) {
  7. super(props);
  8. let {
  9. ModuleID,
  10. EventSystem
  11. } = props;
  12. let eventName = ModuleID + "HitCheck"
  13. EventSystem && EventSystem.on(eventName, ({x,y}) => {
  14. return true;
  15. });
  16. this.isTemplate = false
  17. //console.log("GEN EV: " , eventName, EventSystem);
  18. this._containerStyle = {
  19. marginLeft: 24,
  20. marginRight: 24
  21. }
  22. }
  23. createAction(action) {
  24. if(!this.props.CoreSystem) {
  25. console.warning("This module was constructed without a CoreSystem");
  26. return;
  27. }
  28. return this.props.CoreSystem.ActionSystem.createAction(action);
  29. }
  30. setContainerStyle(style) {
  31. this._containerStyle = style;
  32. }
  33. display() {
  34. throw new Error("You must extend this base Module and override display method!");
  35. }
  36. render() {
  37. return <View ModuleID={this.props.ModuleID} style={[{overflow:'hidden'}]} MY_WRAPPER_FROM_BASE_MODULE={true}>
  38. {this.display()}
  39. </View>
  40. // throw new Error("You must extend this base Module and override render method!");
  41. }
  42. getProps() {
  43. return Resolver(this.constructor.Inputs, this.props);
  44. }
  45. }