import React from 'react'; import {StyleSheet, View, Text} from 'react-native'; import Library from 'trapilib/dist/lib'; import { TextInput } from 'react-native'; import TextEditor from '../Components/TextEditor'; // import Numbers from '../Components/Numbers'; // import ColorEditor from '../Components/ColorEditor'; import TypeHandler from '../Components/TypeHandler.js'; let { CoreSystem, ViewSystem, ViewNode, DataTypes } = Library; export default class SideBar{ constructor(CoreSystem){ this.CoreSystem = CoreSystem; } onUpdate(fn){ this.__onUpdate = fn } forceUpdate(props){ this.__onUpdate && this.__onUpdate(props); } editNode(text,key){ this.viewNode.props[key] = text; this.forceUpdate(); } render(){ console.log("DO I EVER COME HEREEEEEEE") let tool = this.tool; let ModuleSystem = this.CoreSystem.ModuleSystem; let CurrentView = this.CoreSystem.getCurrentView(); let Routing = this.CoreSystem.Routing; let Structure = {}; if (tool) { console.log(tool) if (tool.selectedNode && tool.selectedNode.isCol && CurrentView.has(tool.selectedNode)) { this.ColNode = tool.selectedNode; this.RowNode = CurrentView.getParent(this.ColNode); if(tool.selectedNode.content && tool.selectedNode.content.value) { this.viewNode = tool.selectedNode.content; console.log("NEVERRRRRRRRRRRRRRRR") Structure = ModuleSystem.fromViewNode(this.viewNode).Inputs; } } } let data = Object.keys(Structure || {}).map((key) => { let Editor = TypeHandler(Structure[key]); let editorProps = { title: key, onChange: (value) => { console.log(typeof value); this.editNode(value, key); } }; console.log(DataTypes) switch(Structure[key].type){ case DataTypes.Types.Integer: editorProps.number = this.viewNode.props[key]; break; case DataTypes.Types.Text: editorProps.text = this.viewNode.props[key]; break; default: //Must create a generic Vuiew Component return () } return }) return ( Side Bar Container style {this.RowNode && Row { CurrentView.setColumns(this.RowNode, parseInt(cols)) this.forceUpdate(); }}/> } Col {data} ) } } const SelectedStyle = StyleSheet.create({ container:{ padding:5, borderWidth:2, borderColor:'green' } }) const PropertiesContainer = StyleSheet.create({ container:{ marginTop:20, borderTopWidth:0.8, borderColor:'#D0D0D0' }, child:{ padding:10 } }) const SideBarStyle = StyleSheet.create({ container:{ padding:1, flex:1, flexDirection:'row' }, title:{ fontSize:20, textAlign:'center', fontFamily:'halvetica', color:'black', borderBottomWidth:1, borderBottomColor:'black' }, body:{ paddingLeft:5, paddingRight:5 } })