Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from lucaorio/develop
Browse files Browse the repository at this point in the history
Added support for Sketch 50
  • Loading branch information
lucaorio committed May 10, 2018
2 parents cccd81c + fcda201 commit 2078305
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions Sketch Styles Generator.sketchplugin/Contents/Sketch/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,24 @@ var compare = function compare(name, styles) {

// create new layer style
var create = function create(name, style, styles, count) {
styles.addSharedStyleWithName_firstInstance(name, style);
if (styles.addSharedStyleWithName_firstInstance) {
styles.addSharedStyleWithName_firstInstance(name, style);
} else {
var s = MSSharedStyle.alloc().initWithName_firstInstance(name, style);
styles.addSharedObject(s);
}
count.created++;
};

// update existing layer style, syncronize the instances
var update = function update(style, pointer, styles, count) {
styles.updateValueOfSharedObject_byCopyingInstance(pointer, style);
styles.synchroniseInstancesOfSharedObject_withInstance(pointer, style);
if (styles.updateValueOfSharedObject_byCopyingInstance) {
styles.updateValueOfSharedObject_byCopyingInstance(pointer, style);
styles.synchroniseInstancesOfSharedObject_withInstance(pointer, style);
} else {
pointer.updateToMatch(style);
pointer.resetReferencingInstances();
}
count.updated++;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"generate"
]
},
"version": "1.3.1",
"version": "1.3.2",
"description": "Programmatically generate Shared Styles based on the layers name",
"homepage": "https://github.com/lucaorio/sketch-styles-generator#readme",
"disableCocoaScriptPreprocessor": true
Expand Down
11 changes: 11 additions & 0 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,16 @@
</description>
<enclosure url="https://github.com/lucaorio/sketch-styles-generator/releases/download/v1.3.1/sketch-styles-generator.zip" sparkle:version="1.3.1" />
</item>
<item>
<title>Sketch Styles Generator 1.3.2</title>
<description>
<![CDATA[
<ul>
<li>Updates for Sketch 50</li>
</ul>
]]>
</description>
<enclosure url="https://github.com/lucaorio/sketch-styles-generator/releases/download/v1.3.2/sketch-styles-generator.zip" sparkle:version="1.3.2" />
</item>
</channel>
</rss>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sketch-styles-generator",
"version": "1.3.1",
"version": "1.3.2",
"description": "Programmatically generate Shared Styles based on the layers name",
"author": "Luca Orio",
"homepage": "https://github.com/lucaorio/sketch-styles-generator#readme",
Expand Down
16 changes: 13 additions & 3 deletions src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,24 @@ const compare = (name, styles) => Object.keys(styles).find(x => x == name);

// create new layer style
const create = (name, style, styles, count) => {
styles.addSharedStyleWithName_firstInstance(name, style);
if (styles.addSharedStyleWithName_firstInstance) {
styles.addSharedStyleWithName_firstInstance(name, style);
} else {
const s = MSSharedStyle.alloc().initWithName_firstInstance(name, style);
styles.addSharedObject(s);
}
count.created++;
};

// update existing layer style, syncronize the instances
const update = (style, pointer, styles, count) => {
styles.updateValueOfSharedObject_byCopyingInstance(pointer, style);
styles.synchroniseInstancesOfSharedObject_withInstance(pointer, style);
if (styles.updateValueOfSharedObject_byCopyingInstance) {
styles.updateValueOfSharedObject_byCopyingInstance(pointer, style);
styles.synchroniseInstancesOfSharedObject_withInstance(pointer, style);
} else {
pointer.updateToMatch(style);
pointer.resetReferencingInstances();
}
count.updated++;
};

Expand Down

0 comments on commit 2078305

Please sign in to comment.