123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- import React from 'react';
- import {StyleSheet, View, Text} from 'react-native';
- import Library from 'trapilib/dist/lib';
- import { TextInput } from 'react-native';
- let {
- CoreSystem,
- ViewSystem,
- ViewNode
- } = Library;
- export default class SideBar{
- constructor(CoreSystem){
- this.CoreSystem = CoreSystem;
- }
- onToolUpdate(props){
- 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,node){
- }
- //TODO Change everything :P
- render(){
- let tool = this.tool;
- console.log("@@@@@@@@@@@@@")
- console.log(tool)
- let ModuleSystem = this.CoreSystem.ModuleSystem;
- let NodeProps = {};
- if(tool){
- if(tool.selectedNode && tool.selectedNode.content && tool.selectedNode.content.value){
- let ctor = tool.selectedNode.content.value
- let namespace = tool.selectedNode.content.namespace
- // give ViewNode
- NodeProps = ModuleSystem.constructors[namespace][ctor].propTypes;
- console.log(NodeProps);
- }
- }
- let data = Object.keys(NodeProps || {}).map((key) => {
- return(
- <View style={SideBarStyle.body}>
- <Text>{key}</Text>
- {key === 'text' ? (
- <TextInput
- style={{height: 40, borderColor: 'gray', borderWidth: 1}}
- onChangeText={(text) => this.editNode(text,node)}
- value={NodeProps[key]}
- />
- ):(null)}
- </View>
- )
- })
- return (
- <View style={SideBarStyle}>
- <Text style={SideBarStyle.title}>Side Bar</Text>
- {data}
- </View>
- )
- }
- }
- 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
- }
- })
|