123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- 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 (<View></View>)
- }
- return <Editor {...editorProps}/>
- })
- return (
- <View>
- <Text style={SideBarStyle.title}>Side Bar</Text>
- <View>
- <Text>Container style</Text>
- {this.RowNode && <View>
- <Text>Row</Text>
- <TextEditor title="Inner Columns"
- text={this.RowNode && CurrentView.getColumns(this.RowNode).length +''}
- onChange={(cols) => {
- CurrentView.setColumns(this.RowNode, parseInt(cols))
- this.forceUpdate();
- }}/>
- </View>}
- <View>
- <Text>Col</Text>
- </View>
- </View>
- <View style={PropertiesContainer.container}>
- {data}
- </View>
-
- </View>
- )
- }
- }
- 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
- }
- })
|