ModuleBar.js 1.8 KB

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