Skip to content

Commit

Permalink
[Feat] Remaster Layout
Browse files Browse the repository at this point in the history
  • Loading branch information
thize committed Jun 9, 2020
1 parent c7a01e0 commit d94b475
Show file tree
Hide file tree
Showing 64 changed files with 1,129 additions and 4,616 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"cSpell.words": [
"Artboard",
"Artboards",
"Bouds",
"scenegraph"
]
}
74 changes: 0 additions & 74 deletions README.md

This file was deleted.

55 changes: 49 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
const { update, show } = require("./src/ui/main_panel_ui");
const scenegraph = require("scenegraph");
const clipboard = require("clipboard");
const { Artboard, SymbolInstance } = require("scenegraph");
const { itemsToDart } = require("./src/items_to_dart");
const { formatDart } = require("./src/widgets/util/format_dart");

module.exports = {
panels: {
main_panel: {
show,
update
function onTapGenerate() {
const items = scenegraph.selection.items;
const hasSelection = items.length > 0;
if (hasSelection) {
const firstItem = items[0];
const isArtboard = firstItem instanceof Artboard;
const isOnlyOneComponent = items.length == 1 && firstItem instanceof SymbolInstance;
if (isOnlyOneComponent) {
generateComponents(items);
} else if (isArtboard) {
generateArtboards(items);
} else {
const dartCode = formatDart(itemsToDart(items) + ";");
console.log(dartCode);
clipboard.copyText(dartCode);
}
} else {
console.log(`Nothing selected`);
}
}

module.exports = {
commands: {
onTapGenerate: onTapGenerate
}
};


function generateArtboards(artboards) {
const dartCode = formatDart(itemsToDart([artboards[0]]) + ";");
console.log(dartCode);
clipboard.copyText(dartCode);
}

function generateComponents(components) {
console.log('generateComponents');
// const componentsWidgets = [];
// components.forEach(component => {
// let widget = generateWidgetFromItems(component.children);
// widget = wrapWithInkWell(component, widget);
// const generatedComponent = formatDart(statelessWidget(component.name, widget));
// componentsWidgets.push(generatedComponent);
// });
// let stringComponents = '';
// componentsWidgets.forEach((e) => stringComponents += e);
// return stringComponents;
}
12 changes: 6 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "Xd to Flutter by Thize",
"name": "Denovo?",
"host": {
"app": "XD",
"minVersion": "21.0"
},
"id": "b9d42c73",
"id": "b9d42c71",
"icons": [
{
"path": "images/icon@1x.png",
Expand All @@ -19,10 +19,10 @@
],
"uiEntryPoints": [
{
"type": "panel",
"label": "UI Panel",
"panelId": "main_panel"
"label": "Generate Selection",
"type": "menu",
"commandId": "onTapGenerate"
}
],
"version": "3.0.0"
"version": "0.0.1"
}
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;
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.

Loading

0 comments on commit d94b475

Please sign in to comment.