ModuleBar.js 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from 'react';
  2. import {StyleSheet, View, Text , Button} from 'react-native';
  3. import { TextInput } from 'react-native';
  4. export default class ModuleBar {
  5. constructor(CS){
  6. this.CoreSystem = CS;
  7. }
  8. selectModule(mod, namespace) {
  9. this.selectedModule = mod;
  10. this.selectedModuleNamespace = namespace;
  11. }
  12. dragStart(ev, data) {
  13. ev.nativeEvent.dataTransfer.setData("MyObject", JSON.stringify(data));
  14. }
  15. render(){
  16. let list = this.CoreSystem.ModuleSystem.list();
  17. let Render = Object.keys(list).map((key, index) => {
  18. let items = Object.keys(list[key]).map((name,ind) => {
  19. return <View key={name} onClick={() => this.selectModule(list[key][name], key)}>
  20. <Text draggable={true} onDragStart={(ev) => this.dragStart(ev, {
  21. namespace: key,
  22. ctor: name
  23. })}>{name}</Text>
  24. </View>
  25. });
  26. return <View key={key}>
  27. <Text>{key}</Text>
  28. {items}
  29. </View>;
  30. })
  31. return Render;
  32. }
  33. }