ModuleBar.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. let prop = {
  20. style:ModPrev,
  21. text:"sdasdasd"
  22. }
  23. return (
  24. <View style={ModPrev.container}>
  25. <View style={ModPrev.NameCont}>
  26. <Text style={ModPrev.name}>{name}</Text>
  27. <Text style={ModPrev.modern}>Modern</Text>
  28. </View>
  29. <View style= {ModPrev.ContentCont} key={name} onClick={() => this.selectModule(list[key][name], key)}>
  30. <View style = {ModPrev.content} draggable={true} onDragStart={(ev) => this.dragStart(ev, {
  31. namespace: key,
  32. ctor: name
  33. })}>
  34. {React.createElement(list[key][name])}
  35. </View>
  36. </View>
  37. </View>)
  38. });
  39. return <View key={key}>
  40. <Text>{key}</Text>
  41. {items}
  42. </View>;
  43. })
  44. return Render;
  45. }
  46. }
  47. const ModPrev = StyleSheet.create({
  48. container:{
  49. marginBottom:34
  50. },
  51. NameCont:{
  52. flex:1,
  53. flexDirection:'row',
  54. justifyContent:"space-between"
  55. },
  56. name:{
  57. textAlign:'left',
  58. fontSize:14,
  59. color:'#707070',
  60. opacity:1,
  61. marginBottom:8,
  62. letterSpacing:0
  63. },
  64. modern:{
  65. color:'#707070',
  66. fontSize:10,
  67. letterSpacing:0.6,
  68. opacity:0.5,
  69. marginTop:5
  70. },
  71. ContentCont:{
  72. backgroundColor:'#F8F8F8',
  73. width:216,
  74. height:99
  75. },
  76. content:{
  77. flex:1,
  78. alignItems: 'center',
  79. justifyContent:'center'
  80. }
  81. })