ModuleBar.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import React from 'react';
  2. import {StyleSheet, View, Text , Button} from 'react-native';
  3. import { TextInput } from 'react-native';
  4. import BaseSystem from './System'
  5. export default class ModuleBar extends BaseSystem {
  6. constructor(CS){
  7. super();
  8. this.CoreSystem = CS;
  9. }
  10. selectModule(mod, namespace) {
  11. this.selectedModule = mod;
  12. this.selectedModuleNamespace = namespace;
  13. }
  14. dragStart(ev, data) {
  15. ev.nativeEvent.dataTransfer.setData("MyObject", JSON.stringify(data));
  16. }
  17. render(){
  18. let list = this.CoreSystem.ModuleSystem.list();
  19. let Render = Object.keys(list).map((key, index) => {
  20. let items = Object.keys(list[key]).map((name,ind) => {
  21. let prop = {
  22. style:ModPrev,
  23. text:"sdasdasd"
  24. }
  25. return (
  26. <View style={ModPrev.container}>
  27. <View style={ModPrev.NameCont}>
  28. <Text style={ModPrev.name}>{name}</Text>
  29. <Text style={ModPrev.modern}>Modern</Text>
  30. </View>
  31. <View style= {ModPrev.ContentCont} key={name} onClick={() => this.selectModule(list[key][name], key)}>
  32. <View style = {ModPrev.content}>
  33. <Text draggable={true} onDragStart={(ev) => this.dragStart(ev, {
  34. namespace: key,
  35. ctor: name
  36. })}>
  37. <View style={ModPrev.previewContainer}>
  38. {/*this.CoreSystem.ModuleSystem.createElementCtor(list[key][name])*/}
  39. </View>
  40. </Text>
  41. </View>
  42. </View>
  43. </View>)
  44. });
  45. return <View key={key}>
  46. <View style={ModPrev.Namespace} onClick={() => {
  47. this.visibleNamespace ?
  48. this.visibleNamespace = null :
  49. this.visibleNamespace = key;
  50. this.forceUpdate();
  51. }}>
  52. <Text style={ModPrev.NamespaceName}>{key}</Text>
  53. </View>
  54. {this.visibleNamespace === key ? items : null}
  55. </View>;
  56. })
  57. return Render;
  58. }
  59. }
  60. const ModPrev = StyleSheet.create({
  61. container:{
  62. paddingTop: 15,
  63. marginBottom:34,
  64. width:219
  65. },
  66. previewContainer: {
  67. minWidth: 50,
  68. minHeight:40,
  69. backgroundColor: 'rgba(255,255,255,0.1)',
  70. borderWidth: 1,
  71. borderColor: 'rgba(0,0,0,0.1)',
  72. shadowColor: "rgba(0,0,0,0.81)",
  73. shadowOffset: {
  74. width: 0,
  75. height: 1
  76. },
  77. shadowOpacity: 0.30,
  78. shadowRadius: 4.65,
  79. elevation: 3,
  80. cursor: 'pointer'
  81. },
  82. NameCont:{
  83. flex:1,
  84. flexDirection:'row',
  85. justifyContent:"space-between"
  86. },
  87. Namespace: {
  88. cursor: 'pointer'
  89. },
  90. NamespaceName: {
  91. fontWeight: 'bold'
  92. },
  93. name:{
  94. textAlign:'left',
  95. fontSize:12,
  96. color:'#707070',
  97. opacity:0.8,
  98. marginBottom:8,
  99. letterSpacing:0,
  100. fontFamily: 'thin'
  101. },
  102. modern:{
  103. color:'#707070',
  104. fontSize:7,
  105. letterSpacing:0.6,
  106. opacity:0.5,
  107. marginTop:5,
  108. textTransform: 'uppercase',
  109. fontFamily: 'thin'
  110. },
  111. ContentCont:{
  112. backgroundColor:'#F8F8F8',
  113. width:216,
  114. padding: 10
  115. },
  116. content:{
  117. flex:1,
  118. alignItems: 'center',
  119. justifyContent:'center'
  120. }
  121. })