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. width:219
  54. },
  55. NameCont:{
  56. flex:1,
  57. flexDirection:'row',
  58. justifyContent:"space-between"
  59. },
  60. name:{
  61. textAlign:'left',
  62. fontSize:14,
  63. color:'#707070',
  64. opacity:1,
  65. marginBottom:8,
  66. letterSpacing:0
  67. },
  68. modern:{
  69. color:'#707070',
  70. fontSize:10,
  71. letterSpacing:0.6,
  72. opacity:0.5,
  73. marginTop:5
  74. },
  75. ContentCont:{
  76. backgroundColor:'#F8F8F8',
  77. width:216,
  78. height:99,
  79. },
  80. content:{
  81. flex:1,
  82. alignItems: 'center',
  83. justifyContent:'center'
  84. }
  85. })