ModuleBar.js 2.0 KB

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