-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,129 additions
and
4,616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"cSpell.words": [ | ||
"Artboard", | ||
"Artboards", | ||
"Bouds", | ||
"scenegraph" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.