import Tool from '../Systems/Tool';
import { View , Text , Button , TextInput , StyleSheet} from 'react-native';
import { Icon } from 'react-native-elements'
import React from 'react';



import Library from 'trapilib/dist/lib';

let {
	CoreSystem,
	ViewSystem,
	ViewNode,
	Node
} = Library; 
export default class Add extends Tool{
	constructor(){
		super()
		this.selectedNode = null;


	}


	editViewNode(CS,node){
		if(!node) return;
		
		if( this.selectedNode ) {
			this.selectedNode.props.selected = false;
			
		}
		node.props = {
			...node.props,
			selected: true
		}

		this.selectedNode = node;
		let viewName = CS.Routing.getCurrentView();
		let View = CS.ViewSystem.getView(viewName);
		let rows = View.getRows(this.selectedNode);
		View.setRows(this.selectedNode,rows.length + 1)
		rows = View.getRows(this.selectedNode)

	

		View.setColumns(rows[rows.length-1],1)
		rows[rows.length-1].props.selected = true;
/*
		rows.forEach((row) => {
			View.setColumns(row,1);
			row.props.selected = true})
*/		
	}


	render(){
		let selectStyle;
		if(this.active){
			selectStyle = {backgroundColor:"#a6a6a6"}
		}else{
			selectStyle = {backgroundColor:"#F1F1F1"}
		}

		return(	
			<View>
				<Icon  name='add'
					color="#606060"
					containerStyle={selectStyle}
	  				/>
			</View>
			)
	}
}

