SideBar.js 1.9 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(props = {}){
  12. this.props = props
  13. this.__onUpdate = null;
  14. console.log("sssd")
  15. }
  16. onToolUpdate(props){
  17. this.__onUpdate = fn
  18. this.props = props;
  19. }
  20. forceUpdate(props){
  21. this.__onUpdate && this.__onUpdate(props);
  22. }
  23. switchTools(toolName){
  24. //will be a switch function
  25. }
  26. someFunction(){
  27. }
  28. getStyle(style) {
  29. if (typeof style === 'number') {
  30. return ReactNativePropRegistry.getByID(style);
  31. }
  32. return style;
  33. }
  34. editNode(text,node){
  35. }
  36. //TODO Change everything :P
  37. render(){
  38. let {
  39. tool
  40. } = this.props
  41. let NodeProps = {};
  42. if(tool){
  43. if(tool.selectedNode){
  44. NodeProps = tool.selectedNode.props
  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. })