1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- 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 (<View></View>)
- }
- return <Editor {...editorProps} key={key}/>
- }
-
- update(key, val) {
- this.props.onChange && this.props.onChange(key, val);
- }
- render() {
- let {
- structure,
- nodeProps
- } = this.props;
- return (
- <View style={styles.container}>
- <View style={styles.row}>
- {this.createHandler(structure, nodeProps, 'width', (val) => this.update('width', val), 'W')}
- {this.createHandler(structure, nodeProps, 'height', (val) => this.update('height', val), 'H')}
- </View>
- <View style={styles.row}>
- {this.createHandler(structure, nodeProps, 'paddingTop', (val) => this.update('paddingTop', val), 'Top')}
- {this.createHandler(structure, nodeProps, 'paddingBottom', (val) => this.update('paddingBottom', val), 'Bottom')}
- </View>
- <View style={styles.row}>
- {this.createHandler(structure, nodeProps, 'marginLeft', (val) => this.update('marginLeft', val), 'Left')}
- {this.createHandler(structure, nodeProps, 'marginRight', (val) => this.update('marginRight', val), 'Right')}
- </View>
- </View>
- );
- }
- }
- 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'
- }
- })
|