ModuleBar.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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={ModPrev.previewContainer}>
  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. paddingTop: 15,
  53. marginBottom:34,
  54. width:219
  55. },
  56. previewContainer: {
  57. minWidth: 50,
  58. minHeight:40,
  59. backgroundColor: 'rgba(255,255,255,0.1)',
  60. borderWidth: 1,
  61. borderColor: 'rgba(0,0,0,0.1)',
  62. shadowColor: "rgba(0,0,0,0.81)",
  63. shadowOffset: {
  64. width: 0,
  65. height: 1
  66. },
  67. shadowOpacity: 0.30,
  68. shadowRadius: 4.65,
  69. elevation: 3,
  70. cursor: 'pointer'
  71. },
  72. NameCont:{
  73. flex:1,
  74. flexDirection:'row',
  75. justifyContent:"space-between"
  76. },
  77. name:{
  78. textAlign:'left',
  79. fontSize:12,
  80. color:'#707070',
  81. opacity:0.8,
  82. marginBottom:8,
  83. letterSpacing:0,
  84. fontFamily: 'thin'
  85. },
  86. modern:{
  87. color:'#707070',
  88. fontSize:7,
  89. letterSpacing:0.6,
  90. opacity:0.5,
  91. marginTop:5,
  92. textTransform: 'uppercase',
  93. fontFamily: 'thin'
  94. },
  95. ContentCont:{
  96. backgroundColor:'#F8F8F8',
  97. width:216,
  98. padding: 10
  99. },
  100. content:{
  101. flex:1,
  102. alignItems: 'center',
  103. justifyContent:'center'
  104. }
  105. })