
import React from 'react';
import Types from '../../lib/Types';
import Module from '../../lib/Module';


import { Accordion as AccordionCtor } from 'native-base';
import { Actionsheet as ActionsheetCtor } from 'native-base';
import { Badge as BadgeCtor } from 'native-base';
import { Body as BodyCtor } from 'native-base';
import { Button as ButtonCtor } from 'native-base';
import { Card as CardCtor } from 'native-base';
import { CardItem as CardItemCtor } from 'native-base';
import { CheckBox as CheckboxCtor } from 'native-base';
import { Container as ContainerCtor } from 'native-base';
import { Content as ContentCtor } from 'native-base';
import { DatePicker as DatePickerCtor } from 'native-base';
import { DeckSwiper as DeckSwiperCtor } from 'native-base';
import { Fab as FabCtor } from 'native-base';
import { Footer as FooterCtor } from 'native-base';
import { FooterTab as FooterTabCtor } from 'native-base';
import { Form as FormCtor } from 'native-base';
import { Gravatar as GravatarCtor } from 'native-base';
import { H1 as H1Ctor } from 'native-base';
import { H2 as H2Ctor } from 'native-base';
import { H3 as H3Ctor } from 'native-base';
import { Header as HeaderCtor } from 'native-base';
import { IconNB as IconNBCtor } from 'native-base';
import { Input as InputCtor } from 'native-base';
import { InputGroup as InputGroupCtor } from 'native-base';
import { Item as ItemCtor } from 'native-base';
import { Label as LabelCtor } from 'native-base';
import { Left as LeftCtor } from 'native-base';
import { List as ListCtor } from 'native-base';
import { ListItem as ListItemCtor } from 'native-base';
import { PickerItem as PickerItemCtor } from 'native-base';
import { Radio as RadioCtor } from 'native-base';
import { Right as RightCtor } from 'native-base';
import { Root as RootCtor } from 'native-base';
import { Segment as SegmentCtor } from 'native-base';
import { Separator as SeparatorCtor } from 'native-base';
import { Spinner as SpinnerCtor } from 'native-base';
import { Subtitle as SubtitleCtor } from 'native-base';
import { SwipeRow as SwipeRowCtor } from 'native-base';
import { Switch as SwitchCtor } from 'native-base';
import { Tab as TabCtor } from 'native-base';
import { TabContainer as TabContainerCtor } from 'native-base';
import { TabHeading as TabHeadingCtor } from 'native-base';
import { Text as TextCtor } from 'native-base';
import { Textarea as TextareaCtor } from 'native-base';
import { Thumbnail as ThumbnailCtor } from 'native-base';
import { Title as TitleCtor } from 'native-base';
import { Toast as ToastCtor } from 'native-base';
import { ToastContainer as ToastContainerCtor } from 'native-base';
import { View as ViewCtor } from 'native-base';

export class Accordion extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <AccordionCtor {...this.props} />
	}
}
export class Actionsheet extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ActionsheetCtor {...this.props} />
	}
}
export class Badge extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			text,
			icon,
			style,
			color,
			...restProps
		} = this.props;
		return <BadgeCtor {...restProps} style={[{flexDirection: 'row'}, style]}>
			{icon ? <IconNBCtor name={icon}  style={{ fontSize: 15, color, lineHeight: 27 }}/> : null}
			{text ? <TextCtor  style={{ fontSize: 15, color, lineHeight: 27 }}>{text}</TextCtor> : null}
		</BadgeCtor>
	}
}
export class Body extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <BodyCtor {...this.props} />
	}
}
export class Button extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			text,
			icon,
			onPress,
			...rest
		} = this.props;
		let run = () => {
			this.createAction(onPress)
		};
		return <ButtonCtor {...rest} onClick={run} onPress={run}>
			{icon ? <IconCtor name={icon} /> : null}
        	{text ? <TextCtor>{text}</TextCtor> : null}
		</ButtonCtor>
	}
}
export class Card extends Module {
	constructor(props) {
		super(props);
		this.CoreSystem = props.CoreSystem;
	}
	display() {
		let {
			header,
			body,
			footer,
			bodyModules,
			...rest
		} = this.props;

		let item = this.renderModule('Button','NativeBase');
		console.log("ITEM : ", item);
		return  <CardCtor {...rest}>
            {header ? <CardItemCtor header>
              <TextCtor>{header}</TextCtor>
            </CardItemCtor>
        	: null}
            <CardItemCtor>
              <BodyCtor>
                <TextCtor>
                  {body}
                </TextCtor>
                {this.moduleArray(bodyModules)}
              </BodyCtor>
            </CardItemCtor>
            {footer ? <CardItemCtor footer>
              <TextCtor>{footer}</TextCtor>
            </CardItemCtor>
        	: null}
        </CardCtor>;
	}
}
export class CardItem extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <CardItemCtor {...this.props} />
	}
}
export class Checkbox extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <CheckboxCtor {...this.props} />
	}
}
export class Container extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ContainerCtor {...this.props} />
	}
}
export class Content extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ContentCtor {...this.props} />
	}
}
export class DatePicker extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <DatePickerCtor {...this.props} />
	}
}
export class DeckSwiper extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <DeckSwiperCtor {...this.props} />
	}
}
export class Fab extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <FabCtor {...this.props} />
	}
}
export class Footer extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <FooterCtor {...this.props} />
	}
}
export class FooterTab extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <FooterTabCtor {...this.props} />
	}
}
export class Form extends Module {
	constructor(props) {
		super(props);
		this.state = {};
	}
	
	submit() {
		this.createAction(this.props.onSubmit);
	}

	change(item, value) {
		this.setState({
			[item]: value 
		});
	}

	display() {
		let {
			inputs,
			button,
			onSubmit,
			...rest
		} = this.props;
		return [
		<FormCtor {...rest}>
            {inputs ? inputs.map((item, index) => {
        	return <ItemCtor key={index} last={index === inputs.length-1}>
	              	<InputCtor placeholder={item} 
	              		placeholderLabel={item} 
	              		value={this.state[item && item.toLowerCase()] || ''}
	              		onChangeText={(value) => this.change(item && item.toLowerCase(), value)}/>
	            </ItemCtor>
	        }) : null}
        </FormCtor>,
	    button ? <ButtonCtor onPress={() => this.submit()}>
	    	<TextCtor>{button}</TextCtor>
	    </ButtonCtor>: null
	    ]
	}
}
export class Gravatar extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <GravatarCtor {...this.props} />
	}
}
export class H1 extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			content,
			...rest
		} = this.props;
		return <H1Ctor {...rest}>
			{content}
		</H1Ctor>
	}
}
export class H2 extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			content,
			...rest
		} = this.props;
		return <H2Ctor {...rest}>
			{content}
		</H2Ctor>
	}
}
export class H3 extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			content,
			...rest
		} = this.props;
		return <H3Ctor {...rest}>
			{content}
		</H3Ctor>
	}
}
export class Header extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <HeaderCtor {...this.props} />
	}
}
export class IconNB extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <IconNBCtor {...this.props} />
	}
}
export class Input extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			icon,
			placeholder,
			...rest
		} = this.props;
		return  <ItemCtor {...rest}>
			<InputCtor placeholder={placeholder}/>
			{icon ? <IconNBCtor active name={icon} /> : null}
		</ItemCtor>;		
	}
}
export class InputGroup extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <InputGroupCtor {...this.props} />
	}
}
export class Item extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			placeholder,
			mod,
			...rest
		} = this.props;
		console.log("RENDERMOD:", mod);
		return <ContentCtor>
		<ItemCtor {...rest}>
			{this.module(mod)}
		</ItemCtor>
		</ContentCtor>;
	}
}
export class Label extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <LabelCtor {...this.props} />
	}
}
export class Left extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <LeftCtor {...this.props} />
	}
}
export class List extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ListCtor {...this.props} />
	}
}
export class ListItem extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ListItemCtor {...this.props} />
	}
}
export class PickerItem extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <PickerItemCtor {...this.props} />
	}
}
export class Radio extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <RadioCtor {...this.props} />
	}
}
export class Right extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <RightCtor {...this.props} />
	}
}
export class Root extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <RootCtor {...this.props} />
	}
}
export class Segment extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <SegmentCtor {...this.props} />
	}
}
export class Separator extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <SeparatorCtor {...this.props} />
	}
}
export class Spinner extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <SpinnerCtor {...this.props} />
	}
}
export class Subtitle extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <SubtitleCtor {...this.props} />
	}
}
export class SwipeRow extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <SwipeRowCtor {...this.props} />
	}
}
export class Switch extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <SwitchCtor {...this.props} />
	}
}
export class Tab extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <TabCtor {...this.props} />
	}
}
export class TabContainer extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <TabContainerCtor {...this.props} />
	}
}
export class TabHeading extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <TabHeadingCtor {...this.props} />
	}
}
export class Text extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			content,
			...rest
		} = this.props
		return <TextCtor {...rest} >
			{content}
		</TextCtor>
	}
}
export class Textarea extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		let {
			...rest
		} = this.props;
		return <TextareaCtor {...rest}>
		</TextareaCtor>
	}
}
export class Thumbnail extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ThumbnailCtor {...this.props} />
	}
}
export class Title extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <TitleCtor {...this.props} />
	}
}
export class Toast extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ToastCtor {...this.props} />
	}
}
export class ToastContainer extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ToastContainerCtor {...this.props} />
	}
}
export class View extends Module {
	constructor(props) {
		super(props);
	}
	display() {
		return <ViewCtor {...this.props} />
	}
}

Text.Inputs = {
	uppercase: new Types.Bool().default(false),
	content: new Types.Text().default("Hello world!")
}
Accordion.Inputs = {
	
}
Actionsheet.Inputs = {
	
}
Body.Inputs = {
	
}
Button.Inputs = {
	text: new Types.Text().default("Press me"),
	onPress: new Types.Action(),
	block: new Types.Bool(),
	primary: new Types.Bool(),
	transparent: new Types.Bool(),
	success: new Types.Bool(),
	danger: new Types.Bool(),
	warning: new Types.Bool(),
	info: new Types.Bool(),
	bordered: new Types.Bool(),
	disabled: new Types.Bool(),
	rounded: new Types.Bool(),
	large: new Types.Bool(),
	small: new Types.Bool(),
	active: new Types.Bool()
}
Badge.Inputs = {
	icon: new Types.Text(),
	text: new Types.Text().require().default("1"),
	color: new Types.Text().color().require().default("rgba(255,255,255,1)"),
	primary: new Types.Bool(),
	success: new Types.Bool(),
	danger: new Types.Bool(),
	warning: new Types.Bool(),
	info: new Types.Bool()
}
Card.Inputs = {
	header: new Types.Text().default("Header"),
	body: new Types.Text().default("Lorem ipsum body bla la trapala"),
	footer: new Types.Text().default("Add footer here"),
	bodyModules: new Types.Array(new Types.Module()),
	texts: new Types.Array(new Types.Text())
}
CardItem.Inputs = {
	header: new Types.Bool(),
	cardBody: new Types.Bool(),
	footer: new Types.Bool(),
	button: new Types.Bool()
}
Checkbox.Inputs = {
	checked: new Types.Bool()
}
Container.Inputs = {
	
}
Content.Inputs = {
	disableKBDismissScroll: new Types.Bool(),
	keyboardShouldPersistTaps: new Types.Text(),
	padder: new Types.Bool()
}
DatePicker.Inputs = {
	
}
DeckSwiper.Inputs = {
	
}
Fab.Inputs = {
	
}
Footer.Inputs = {
	
}
FooterTab.Inputs = {
	
}
Form.Inputs = {
	inputs: new Types.Array(new Types.Text()),
	button: new Types.Text().default('Submit'),
	onSubmit: new Types.Action()
}
Gravatar.Inputs = {
	email: new Types.Text().require(),
	size: new Types.Real(),
	circular: new Types.Bool(),
	square: new Types.Bool()
}
H1.Inputs = {
	...Text.Inputs
}
H2.Inputs = {
	...Text.Inputs
}
H3.Inputs = {
	...Text.Inputs	
}
Header.Inputs = {
	searchBar: new Types.Bool(),
	rounded: new Types.Bool()
}
IconNB.Inputs = {
	
}
Item.Inputs = {
	mod: new Types.Module(),
	inlineLabel: new Types.Bool(),
	floatingLabel: new Types.Bool(),
	stackedLabel: new Types.Bool(),
	fixedLabel: new Types.Bool(),
	success: new Types.Bool(),
	error: new Types.Bool()
}
Input.Inputs = {
	icon: new Types.Text(),
	placeholder: new Types.Text(),
	...Item.Inputs
}
InputGroup.Inputs = {
	regular: new Types.Bool(),
	underline: new Types.Bool(),
	rounded: new Types.Bool(),
	success: new Types.Bool(),
	error: new Types.Bool(),
	disabled: new Types.Bool()
}
Label.Inputs = {
	floatBack: new Types.Real()
}
Left.Inputs = {
	
}
List.Inputs = {
	
}
ListItem.Inputs = {
	itemDivider: new Types.Bool(),
	button: new Types.Bool()
}
PickerItem.Inputs = {
	
}
Radio.Inputs = {
	selected: new Types.Bool(),
	standardStyle: new Types.Bool()
}
Right.Inputs = {
	
}
Root.Inputs = {
	
}
Segment.Inputs = {
	
}
Separator.Inputs = {
	
}
Spinner.Inputs = {
	color: new Types.Text(),
	inverse: new Types.Bool()
}
Subtitle.Inputs = {
	
}
SwipeRow.Inputs = {
	
}
Switch.Inputs = {
	
}
Tab.Inputs = {
	
}
TabContainer.Inputs = {
	
}
TabHeading.Inputs = {
	
}
Textarea.Inputs = {
	placeholder: new Types.Text(),
	rowSpan: new Types.Real(),
	bordered: new Types.Bool(),
	underline: new Types.Bool()
}
Thumbnail.Inputs = {
	square: new Types.Bool(),
	circular: new Types.Bool(),
	size: new Types.Real()
}
Title.Inputs = {
	
}
Toast.Inputs = {
	
}
ToastContainer.Inputs = {
	
}
View.Inputs = {
	
}

export default { 
	// Accordion,
	// Actionsheet,
	Badge,
	// Body,
	Button,
	Card,
	// CardItem,
	Checkbox,
	// Container,
	// Content,
	// DatePicker,
	// DeckSwiper,
	// Fab,
	// Footer,
	// FooterTab,
	Form,
	// Gravatar,
	H1,
	H2,
	H3,
	// Header,
	IconNB,
	Input,
	// InputGroup,
	// Item,
	// Label,
	// Left,
	// List,
	// ListItem,
	// PickerItem,
	Radio,
	// Right,
	// Root,
	// Segment,
	// Separator,
	// Spinner,
	// Subtitle,
	// SwipeRow,
	// Switch,
	// Tab,
	// TabContainer,
	// TabHeading,
	// Text,
	// Textarea,
	// Thumbnail,
	// Title,
	// Toast,
	// ToastContainer,
	// View 
}