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';
let {
CoreSystem,
ViewSystem,
ViewNode
} = Library;
export default class SideBar{
constructor(CoreSystem){
this.CoreSystem = CoreSystem;
}
onUpdate(fn){
this.__onUpdate = fn
}
forceUpdate(props){
this.__onUpdate && this.__onUpdate(props);
}
switchTools(toolName){
//will be a switch function
}
someFunction(){
}
getStyle(style) {
if (typeof style === 'number') {
return ReactNativePropRegistry.getByID(style);
}
return style;
}
editNode(text,key){
console.log(text,key);
this.viewNode.props[key] = text;
this.forceUpdate();
}
//TODO Change everything :P
render(){
let tool = this.tool;
console.log("@@@@@@@@@@@@@")
console.log(tool)
let ModuleSystem = this.CoreSystem.ModuleSystem;
let CurrentView = this.CoreSystem.getCurrentView();
let Routing = this.CoreSystem.Routing;
let Structure = {};
if(tool){
if(tool.selectedNode && tool.selectedNode.isCol)
{
this.ColNode = tool.selectedNode;
this.RowNode = CurrentView.getParent(this.ColNode);
console.log("ROWNODE" , this.RowNode);
console.log("ColNode" , this.ColNode);
console.log("viewNode" , this.viewNode);
if(tool.selectedNode.content && tool.selectedNode.content.value){
this.viewNode = tool.selectedNode.content;
Structure = ModuleSystem.fromViewNode(this.viewNode).Inputs;
}
}
}
let data = Object.keys(Structure || {}).map((key) => {
return(
{key}
{key === 'text' ? (
this.editNode(text, key)}
value={this.viewNode.props[key]}
/>
):(null)}
)
})
console.log("ROW NODE DATA DATA" , this.RowNode , this.RowNode && CurrentView.getColumns(this.RowNode).length);
return (
Side Bar
Container style
{this.RowNode &&
Row
{
console.log(cols, "COLS");
CurrentView.setColumns(this.RowNode, parseInt(cols))
this.forceUpdate();
}}/>
}
Col
{data}
)
}
}
const SelectedStyle = StyleSheet.create({
container:{
padding:5,
borderWidth:2,
borderColor:'green'
}
})
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
}
})