SideBar.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. let ModuleSystem = this.CoreSystem.ModuleSystem;
  37. let NodeProps = {};
  38. if(tool){
  39. if(tool.selectedNode && tool.selectedNode.content && tool.selectedNode.content.value){
  40. let ctor = tool.selectedNode.content.value
  41. let namespace = tool.selectedNode.content.namespace
  42. // give ViewNode
  43. NodeProps = ModuleSystem.constructors[namespace][ctor].propTypes;
  44. console.log(NodeProps);
  45. }
  46. }
  47. let data = Object.keys(NodeProps || {}).map((key) => {
  48. return(
  49. <View style={SideBarStyle.body}>
  50. <Text>{key}</Text>
  51. {key === 'text' ? (
  52. <TextInput
  53. style={{height: 40, borderColor: 'gray', borderWidth: 1}}
  54. onChangeText={(text) => this.editNode(text,node)}
  55. value={NodeProps[key]}
  56. />
  57. ):(null)}
  58. </View>
  59. )
  60. })
  61. return (
  62. <View style={SideBarStyle}>
  63. <Text style={SideBarStyle.title}>Side Bar</Text>
  64. {data}
  65. </View>
  66. )
  67. }
  68. }
  69. const SelectedStyle = StyleSheet.create({
  70. container:{
  71. padding:5,
  72. borderWidth:2,
  73. borderColor:'green'
  74. }
  75. })
  76. const SideBarStyle = StyleSheet.create({
  77. container:{
  78. padding:1,
  79. flex:1,
  80. flexDirection:'row'
  81. },
  82. title:{
  83. fontSize:20,
  84. textAlign:'center',
  85. fontFamily:'halvetica',
  86. color:'black',
  87. borderBottomWidth:1,
  88. borderBottomColor:'black'
  89. },
  90. body:{
  91. paddingLeft:5,
  92. paddingRight:5
  93. }
  94. })