ModuleBar.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. },
  71. NameCont:{
  72. flex:1,
  73. flexDirection:'row',
  74. justifyContent:"space-between"
  75. },
  76. name:{
  77. textAlign:'left',
  78. fontSize:12,
  79. color:'#707070',
  80. opacity:0.8,
  81. marginBottom:8,
  82. letterSpacing:0,
  83. fontFamily: 'thin'
  84. },
  85. modern:{
  86. color:'#707070',
  87. fontSize:7,
  88. letterSpacing:0.6,
  89. opacity:0.5,
  90. marginTop:5,
  91. textTransform: 'uppercase',
  92. fontFamily: 'thin'
  93. },
  94. ContentCont:{
  95. backgroundColor:'#F8F8F8',
  96. width:216,
  97. padding: 10
  98. },
  99. content:{
  100. flex:1,
  101. alignItems: 'center',
  102. justifyContent:'center'
  103. }
  104. })