Skip to content

Commit

Permalink
3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thize committed Jun 13, 2020
2 parents 9abf6bc + a367b55 commit 1163e96
Show file tree
Hide file tree
Showing 67 changed files with 2,579 additions and 2,586 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Adobe XD Flutter Code Generate - Plugin
<a href="https://github.com/thize/xd-to-flutter/releases"><img src="https://img.shields.io/badge/Xd%20to%20Flutter-v3.0.0-blue"/></a>
<a href="https://github.com/thize/xd-to-flutter/releases"><img src="https://img.shields.io/badge/Xd%20to%20Flutter-v3.1.0-blue"/></a>

⚠️ **If you encounter an issue or have any feedback which you think could improve Plugin, please open an issue [here](https://github.com/thize/xd-to-flutter/issues)**

Expand Down
14 changes: 14 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
const { update, show } = require("./src/ui/main_panel_ui");
const { onTapGenerate } = require("./src/generate");
const { exportColor } = require("./src/color");

module.exports = {
panels: {
main_panel: {
show,
update
}
},
commands: {
onTapGenerate: onTapGenerate,
exportColor: exportColor
}
};


/*
TODO:
! Android Adaptive icon
! Mask
! Grid
*/
22 changes: 20 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"app": "XD",
"minVersion": "21.0"
},
"id": "b9d42c73",
"id": "b9d42c71",
"icons": [
{
"path": "images/icon@1x.png",
Expand All @@ -22,7 +22,25 @@
"type": "panel",
"label": "UI Panel",
"panelId": "main_panel"
},
{
"label": "Copy Selected",
"type": "menu",
"commandId": "onTapGenerate",
"shortcut": {
"mac": "Cmd+W",
"win": "Ctrl+W"
}
},
{
"label": "Copy Selected Item Color",
"type": "menu",
"commandId": "exportColor",
"shortcut": {
"mac": "Cmd+F",
"win": "Ctrl+F"
}
}
],
"version": "3.0.1"
"version": "3.1.0"
}
29 changes: 29 additions & 0 deletions src/bounds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class Bounds {
/**
* @param {Node} node
* @param {number} x1
* @param {number} x2
* @param {number} y1
* @param {number} y2
*/
constructor(node, parentBouds, x1, x2, y1, y2) {
if (!node && !parentBouds) {
this.x1 = x1
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
} else if (!node) {
this.x1 = parentBouds.x1
this.x2 = parentBouds.x2;
this.y1 = parentBouds.y1;
this.y2 = parentBouds.y2;
} else {
this.x1 = node.globalBounds.x;
this.x2 = this.x1 + node.globalBounds.width;
this.y1 = node.globalBounds.y;
this.y2 = this.y1 + node.globalBounds.height;
}
}
}

exports.Bounds = Bounds;
71 changes: 71 additions & 0 deletions src/color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const { getColor } = require("./widgets/util/color");
const { exportDialog } = require("./ui/dialogs/dialogs");

let clipboard = require("clipboard");
let scenegraph = require("scenegraph")

let withErro;
let color;

const keydownFunc = function (event) {
try {
const key = event.key;
if (key == 1) {
color = exportFill();
} else if (key == 2) {
color = exportStroke();
} else if (key == 3) {
color = exportShadow();
} else if (key == 'Escape') {
} else {
withErro = 'invalidKey';
}
} catch (error) {
withErro = true;
}
if (color) clipboard.copyText(color);
return false;
};

async function exportColor() {
withErro = null;
color = null;
const node = scenegraph.selection.items[0];
if (node.children.length > 1 || scenegraph.selection.items.length > 1) {
await exportDialog("Select only one item", 'Ok', 'Tap any key to close');
} else {
document.addEventListener('keydown', keydownFunc);
await exportDialog("Copy Item Color, Tap:", 'Cancelar', "1 to Fill<br>2 to Stroke<br>3 to Shadow");
document.removeEventListener('keydown', keydownFunc);
if (withErro != null) {
if (withErro == 'invalidKey') {
await exportColor();
} else {
await exportDialog("Error", 'Ok', 'Tap any key to close');
}
} else {
if (color != null) {
await exportDialog("Success", 'Ok', 'Tap any key to close');
}
}
}
}

function exportFill() {
const node = scenegraph.selection.items[0];
return getColor(node.fill);
}

function exportStroke() {
const node = scenegraph.selection.items[0];
return getColor(node.stroke);
}

function exportShadow() {
const node = scenegraph.selection.items[0];
return getColor(node.shadow.color);
}

module.exports = {
exportColor: exportColor,
};
88 changes: 0 additions & 88 deletions src/core/functions/export/app_icon.js

This file was deleted.

33 changes: 0 additions & 33 deletions src/core/functions/export/artboards.js

This file was deleted.

68 changes: 0 additions & 68 deletions src/core/functions/export/color.js

This file was deleted.

Loading

0 comments on commit 1163e96

Please sign in to comment.