import Yoga from 'yoga-layout-prebuilt';

const applyMarginStyles = (node, style) => {
	if (style.margin) {
		node.setMargin(Yoga.EDGE_TOP, style.margin);
		node.setMargin(Yoga.EDGE_BOTTOM, style.margin);
		node.setMargin(Yoga.EDGE_START, style.margin);
		node.setMargin(Yoga.EDGE_END, style.margin);
	}

	if (style.marginX) {
		node.setMargin(Yoga.EDGE_START, style.marginX);
		node.setMargin(Yoga.EDGE_END, style.marginX);
	}

	if (style.marginY) {
		node.setMargin(Yoga.EDGE_TOP, style.marginY);
		node.setMargin(Yoga.EDGE_BOTTOM, style.marginY);
	}

	if (style.marginTop) {
		node.setMargin(Yoga.EDGE_TOP, style.marginTop);
	}

	if (style.marginBottom) {
		node.setMargin(Yoga.EDGE_BOTTOM, style.marginBottom);
	}

	if (style.marginLeft) {
		node.setMargin(Yoga.EDGE_START, style.marginLeft);
	}

	if (style.marginRight) {
		node.setMargin(Yoga.EDGE_END, style.marginRight);
	}
};

const applyPaddingStyles = (node, style) => {
	if (style.padding) {
		node.setMargin(Yoga.EDGE_TOP, style.padding);
		node.setMargin(Yoga.EDGE_BOTTOM, style.padding);
		node.setMargin(Yoga.EDGE_LEFT, style.padding);
		node.setMargin(Yoga.EDGE_RIGHT, style.padding);
	}

	if (style.paddingX) {
		node.setMargin(Yoga.EDGE_LEFT, style.paddingX);
		node.setMargin(Yoga.EDGE_RIGHT, style.paddingX);
	}

	if (style.paddingY) {
		node.setMargin(Yoga.EDGE_TOP, style.paddingY);
		node.setMargin(Yoga.EDGE_BOTTOM, style.paddingY);
	}

	if (style.paddingTop) {
		node.setMargin(Yoga.EDGE_TOP, style.paddingTop);
	}

	if (style.paddingBottom) {
		node.setMargin(Yoga.EDGE_BOTTOM, style.paddingBottom);
	}

	if (style.paddingLeft) {
		node.setMargin(Yoga.EDGE_LEFT, style.paddingLeft);
	}

	if (style.paddingRight) {
		node.setMargin(Yoga.EDGE_RIGHT, style.paddingRight);
	}
};

const applyFlexStyles = (node, style) => {
	if (style.flexGrow) {
		node.setFlexGrow(style.flexGrow);
	}

	if (style.flexShrink) {
		node.setFlexShrink(style.flexShrink);
	}

	if (style.flexDirection) {
		if (style.flexDirection === 'row') {
			node.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
		}

		if (style.flexDirection === 'row-reverse') {
			node.setFlexDirection(Yoga.FLEX_DIRECTION_ROW_REVERSE);
		}

		if (style.flexDirection === 'column') {
			node.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN);
		}

		if (style.flexDirection === 'column-reverse') {
			node.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN_REVERSE);
		}
	}

	if (style.alignItems) {
		if (style.alignItems === 'flex-start') {
			node.setAlignItems(Yoga.ALIGN_FLEX_START);
		}

		if (style.alignItems === 'center') {
			node.setAlignItems(Yoga.ALIGN_CENTER);
		}

		if (style.alignItems === 'flex-end') {
			node.setAlignItems(Yoga.ALIGN_FLEX_END);
		}
	}

	if (style.justifyContent) {
		if (style.justifyContent === 'flex-start') {
			node.setJustifyContent(Yoga.JUSTIFY_FLEX_START);
		}

		if (style.justifyContent === 'center') {
			node.setJustifyContent(Yoga.JUSTIFY_CENTER);
		}

		if (style.justifyContent === 'flex-end') {
			node.setJustifyContent(Yoga.JUSTIFY_FLEX_END);
		}

		if (style.justifyContent === 'space-between') {
			node.setJustifyContent(Yoga.JUSTIFY_SPACE_BETWEEN);
		}

		if (style.justifyContent === 'space-around') {
			node.setJustifyContent(Yoga.JUSTIFY_SPACE_AROUND);
		}
	}
};

export default (node, style = {}) => {
	applyMarginStyles(node, style);
	applyPaddingStyles(node, style);
	applyFlexStyles(node, style);
};

@@ -949,38 +949,39 @@
 ng) %7B%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_TOP, 
@@ -998,38 +998,39 @@
 ing);%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_BOTTO
@@ -1050,38 +1050,39 @@
 ing);%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_LEFT,
@@ -1100,38 +1100,39 @@
 ing);%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_RIGHT
@@ -1178,38 +1178,39 @@
 gX) %7B%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_LEFT,
@@ -1229,38 +1229,39 @@
 ngX);%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_RIGHT
@@ -1308,38 +1308,39 @@
 gY) %7B%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_TOP, 
@@ -1358,38 +1358,39 @@
 ngY);%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_BOTTO
@@ -1440,38 +1440,39 @@
 op) %7B%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_TOP, 
@@ -1524,38 +1524,39 @@
 om) %7B%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_BOTTO
@@ -1612,38 +1612,39 @@
 ft) %7B%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_LEFT,
@@ -1697,38 +1697,39 @@
 ht) %7B%0A%09%09node.set
-Marg
+Padd
 in
+g
 (Yoga.EDGE_RIGHT

Use Yoga padding methods