import React, { useState } from 'react';
import {View , Text, TextInput, Button,StyleSheet} from 'react-native';
import { Icon } from 'react-native-elements'
import TypeHandler from './TypeHandler.js';
import Library from 'trapilib/dist/lib';
let { DataTypes } = Library;
export default class ContainerEditor extends React.Component {
constructor(props) {
super(props);
}
createHandler(Structure, viewNodeProps, key, onChange, title) {
let Editor = TypeHandler(Structure);
let editorProps = {
title: title || key,
onChange: (value) => {
onChange && onChange(value, key)
}
};
switch(Structure.type){
case DataTypes.Types.Array:
editorProps.value = viewNodeProps[key];
break;
case DataTypes.Types.Integer:
case DataTypes.Types.Real:
case DataTypes.Types.Bool:
editorProps.number = viewNodeProps[key];
break;
case DataTypes.Types.Text:
editorProps.text = viewNodeProps[key];
break;
default:
//Must create a generic Vuiew Component
return ()
}
return
}
update(key, val) {
this.props.onChange && this.props.onChange(key, val);
}
render() {
let {
structure,
nodeProps
} = this.props;
return (
{this.createHandler(structure, nodeProps, 'width', (val) => this.update('width', val), 'W')}
{this.createHandler(structure, nodeProps, 'height', (val) => this.update('height', val), 'H')}
);
}
}
const styles = StyleSheet.create({
container:{
padding:15,
flexDirection: 'column',
justifyContent: 'space-around',
borderBottomColor: '#B4B4B4',
borderBottomWidth: 1
},
row: {
flexDirection: 'row',
justifyContent: 'space-around'
},
defaultInput: {
marginTop:6,
borderWidth:1,
width:200
},
title: {
},
iconStyle: {
fontSize: 18,
opacity: 0.6,
cursor: 'pointer'
}
})