SideBar.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import React from 'react';
  2. import {StyleSheet, View, Text} from 'react-native';
  3. import Library from 'trapilib/dist/lib';
  4. import { TextInput } from 'react-native';
  5. let {
  6. CoreSystem,
  7. ViewSystem,
  8. ViewNode
  9. } = Library;
  10. export default class SideBar{
  11. constructor(CoreSystem){
  12. this.CoreSystem = CoreSystem;
  13. }
  14. onToolUpdate(props){
  15. this.__onUpdate = fn
  16. }
  17. forceUpdate(props){
  18. this.__onUpdate && this.__onUpdate(props);
  19. }
  20. switchTools(toolName){
  21. //will be a switch function
  22. }
  23. someFunction(){
  24. }
  25. getStyle(style) {
  26. if (typeof style === 'number') {
  27. return ReactNativePropRegistry.getByID(style);
  28. }
  29. return style;
  30. }
  31. editNode(text,node){
  32. }
  33. //TODO Change everything :P
  34. render(){
  35. let tool = this.tool;
  36. console.log("@@@@@@@@@@@@@")
  37. console.log(tool)
  38. let ModuleSystem = this.CoreSystem.ModuleSystem;
  39. let NodeProps = {};
  40. if(tool){
  41. if(tool.selectedNode && tool.selectedNode.content && tool.selectedNode.content.value){
  42. let ctor = tool.selectedNode.content.value
  43. let namespace = tool.selectedNode.content.namespace
  44. // give ViewNode
  45. NodeProps = ModuleSystem.constructors[namespace][ctor].propTypes;
  46. console.log(NodeProps);
  47. }
  48. }
  49. let data = Object.keys(NodeProps || {}).map((key) => {
  50. return(
  51. <View style={SideBarStyle.body}>
  52. <Text>{key}</Text>
  53. {key === 'text' ? (
  54. <TextInput
  55. style={{height: 40, borderColor: 'gray', borderWidth: 1}}
  56. onChangeText={(text) => this.editNode(text,node)}
  57. value={NodeProps[key]}
  58. />
  59. ):(null)}
  60. </View>
  61. )
  62. })
  63. return (
  64. <View style={SideBarStyle}>
  65. <Text style={SideBarStyle.title}>Side Bar</Text>
  66. {data}
  67. </View>
  68. )
  69. }
  70. }
  71. const SelectedStyle = StyleSheet.create({
  72. container:{
  73. padding:5,
  74. borderWidth:2,
  75. borderColor:'green'
  76. }
  77. })
  78. const SideBarStyle = StyleSheet.create({
  79. container:{
  80. padding:1,
  81. flex:1,
  82. flexDirection:'row'
  83. },
  84. title:{
  85. fontSize:20,
  86. textAlign:'center',
  87. fontFamily:'halvetica',
  88. color:'black',
  89. borderBottomWidth:1,
  90. borderBottomColor:'black'
  91. },
  92. body:{
  93. paddingLeft:5,
  94. paddingRight:5
  95. }
  96. })