import React from 'react';
import Module from '../../lib/Module';
import { View , StyleSheet , Text} from 'react-native';
import Types from '../../lib/Types';

import BaseContainer from '../BaseContainer/index';
import ImageComp from '../Image/index';
import TextComp from '../Text/index';

import { ViewNode, Node } from '../../lib/systems/ViewSystem';

/*let base1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "BaseContainer",  {width:320,height:209}))
let base2 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "BaseContainer",  {width:320,height:209}))
let Image1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Image",  {width:320,height:209}))
let Text1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Text", {text:"hi there"}))*/
const defaultText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eget sapien justo. Nunc justo nunc, tristique sollicitudin sodales et, rhoncus vel augue. Mauris vel elit turpis. Vivamus hendrerit faucibus tortor, eget molestie turpis mattis vel. Cras maximus nibh vitae euismod lobortis. Sed iaculis quis lectus non rhoncus. Quisque non purus vel risus venenatis convallis eu at turpis. Cras accumsan quam eu dolor dignissim accumsan. Vestibulum sed orci facilisis, lacinia nibh vitae, egestas massa. Integer sit amet dui velit. Suspendisse ut nibh massa. Fusce condimentum semper odio, et hendrerit nisi venenatis consequat. Nam sed nibh eros. Nulla facilisi."

export default class BlogFeed extends Module {

	constructor(props){
		super(props)
		this.isTemplate = true;
		
		this.configure();	
		
	}


	configure(){
		if(this.props.CoreSystem){
			let CurrentView = this.props.CoreSystem.getCurrentView();
		 	let node = CurrentView.getNode(this.props.NodeID)
		 	let children = CurrentView.getChildren(node);
			let base1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "BaseContainer",  {width:375,height:209}))
			let base2 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "BaseContainer",  {width:375,height:209}))
			let Image1 = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Image"))
			
			let wrapper = new Node("SS"+ Math.random(), {flexDirection:"row",justifyContent:"space-between",alignItems:"flex-end",height:40},new ViewNode("S"+Math.random(), "BaseContainer", {}))
			let Title = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Text", {text:"This is the post Title",color:"rgba(112, 112, 112, 1)",fontSize:17,fontFamily:"bold"}))
		 	let BookMark = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Icon", {}))

		 	let subtitle = new Node("SS"+ Math.random(), {height:25},new ViewNode("S"+Math.random(), "Text", {text:"This is the subtitle",color:"rgba(112, 112, 112, 1)",fontSize:14,fontFamily:"thin"}))
		 	let MainText = new Node("SS"+ Math.random(), {},new ViewNode("S"+Math.random(), "Text", {text:defaultText,color:"rgba(112, 112, 112, 1)",fontSize:14}))
		 	


		 	let wrapperProfile = new Node("SS"+ Math.random(), {flexDirection:"row",height:40},new ViewNode("S"+Math.random(), "BaseContainer", {}))
			
		 	let ImageProfile = new Node("SS"+ Math.random(), {width:34,height:34},new ViewNode("S"+Math.random(), "Image",{source:require('../Image/assets/profile.png'),width:32,height:32}))
		 	let ImageWrapper = new Node("SS"+ Math.random(), {flexDirection:"row",justifyContent:"center",alignItems:'center',height:40},new ViewNode("S"+Math.random(), "BaseContainer", {}))
			
		 	let UserWrapper = new Node("SS"+ Math.random(), {flexDirection:"column",height:40,flexGrow:1},new ViewNode("S"+Math.random(), "BaseContainer", {}))
			
		 	let user = new Node("SS"+ Math.random(), {height:20},new ViewNode("S"+Math.random(), "Text", {text:"Alexandra papadopoulou ",color:"rgba(112, 112, 112, 1)",fontSize:14,fontFamily:"thin"}))
		 	let userjob = new Node("SS"+ Math.random(), {height:20},new ViewNode("S"+Math.random(), "Text", {text:"Market Analyst ",color:"rgba(112, 112, 112, 1)",fontSize:14,fontFamily:"thin"}))
		 	

		 	if(!CurrentView.has(base1)) CurrentView.addViewNode(base1 , node );
		 	
		 	if(!CurrentView.has(base2.id)) CurrentView.addViewNode( base2 ,node);
		 	if(!CurrentView.has(Image1.id)) CurrentView.addViewNode(Image1,base1)
			

			if(!CurrentView.has(wrapper.id)) CurrentView.addViewNode(wrapper , base2);
		 		
		 	if(!CurrentView.has(Title.id)) CurrentView.addViewNode(Title , wrapper);
		 	if(!CurrentView.has(BookMark.id)) CurrentView.addViewNode(BookMark , wrapper);



		 	if(!CurrentView.has(subtitle.id)) {
				CurrentView.addViewNode(subtitle , base2);
		 		
		 	}

		 	// #######################

		 	if(!CurrentView.has(wrapperProfile.id)){
		 		CurrentView.addViewNode(wrapperProfile,base2);
		 		
		 	}

		 	if(!CurrentView.has(ImageWrapper)) CurrentView.addViewNode(ImageWrapper,wrapperProfile);
			if(!CurrentView.has(ImageProfile)) CurrentView.addViewNode(ImageProfile,ImageWrapper);
			if(!CurrentView.has(UserWrapper)) CurrentView.addViewNode(UserWrapper,wrapperProfile);


		 	if(!CurrentView.has(user)) CurrentView.addViewNode(user,UserWrapper)
		 	if(!CurrentView.has(userjob)) {
		 		CurrentView.addViewNode(userjob,UserWrapper)
				this.props.CoreSystem.forceUpdate();
		 	};
		 	

		 	if(!CurrentView.has(MainText.id)){
		 		CurrentView.addViewNode(MainText , base2);
		 		this.props.CoreSystem.forceUpdate();
		 	}	
	 	}
	}

	display(){
		return(
			<View>

				
			</View>
			)
	}
}


BlogFeed.Inputs = {

}