Skip to content

Commit

Permalink
提交一个WeSketch新形象
Browse files Browse the repository at this point in the history
  • Loading branch information
bugluo committed Oct 26, 2017
1 parent f2abb00 commit a4ad4a3
Show file tree
Hide file tree
Showing 46 changed files with 130 additions and 88 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file modified WeSketch.sketchplugin/Contents/Resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified WeSketch.sketchplugin/Contents/Resources/minicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion WeSketch.sketchplugin/Contents/Sketch/checkForUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function checkForUpdate(context, auto) {
if (auto && updateAvailable == false) {
return false;
}
var updateAlert = COSAlertWindow.new();
var updateAlert = dialog(context);

updateAlert.setMessageText(updateAvailable ? i18.m2 : i18.m3);
if (updateAvailable) {
Expand Down
2 changes: 1 addition & 1 deletion WeSketch.sketchplugin/Contents/Sketch/codeSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var codeKey = "com.sketchplugins.wechat.codetype";
var onRun = function (context) {
var i18 = _(context).codeSetting;

var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m1);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.setMessageText(i18.m3);
Expand Down
2 changes: 1 addition & 1 deletion WeSketch.sketchplugin/Contents/Sketch/colorReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function colorReplace(context) {
}

function createUserInterface(colorToFind) {
userInterface = COSAlertWindow.new(); // 创建弹框
userInterface = dialog(context); // 创建弹框

userInterface.setMessageText(i18.m1);

Expand Down
25 changes: 23 additions & 2 deletions WeSketch.sketchplugin/Contents/Sketch/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ var _ = function (context) {
return i18Content;
};

function dialog(context) {
var iconImage = NSImage.alloc().initByReferencingFile(context.plugin.urlForResourceNamed("icon.png").path());
var alert = COSAlertWindow.new();
if (iconImage) {
alert.setIcon(iconImage);
}
return alert;
}

function errorDialog(context,content) {
var iconImage = NSImage.alloc().initByReferencingFile(context.plugin.urlForResourceNamed("icon.png").path());
var alert = COSAlertWindow.new();
if (iconImage) {
alert.setIcon(iconImage);
}
alert.addButtonWithTitle(_(context).checkForUpdate.m9);

alert.setMessageText(_(context).checkForUpdate.m10);
alert.setInformativeText(content);
return alert.runModal();
}

function initDefaults(pluginDomain, initialValues) {
kPluginDomain = pluginDomain;
Expand Down Expand Up @@ -142,7 +163,7 @@ function get(args) {
if (jsonData.status == 200) {
return jsonData;
} else {
NSApp.displayDialog(jsonData.msg);
errorDialog(context,jsonData.msg);
return jsonData;
}
}
Expand All @@ -155,7 +176,7 @@ function post(args) {
if (jsonData.status == 200) {
return jsonData;
} else {
NSApp.displayDialog(jsonData.msg);
errorDialog(context,jsonData.msg);
return jsonData;
}
}
Expand Down
32 changes: 16 additions & 16 deletions WeSketch.sketchplugin/Contents/Sketch/commonPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ var buildPreview = function (context) {
var setIndex = function (context) {
var i18 = _(context).commonPreview;
if (context.selection.length == 0) {
return NSApp.displayDialog(i18.m1);
return errorDialog(context,i18.m1);
} else {
var selection = context.selection[0];
if (selection.className() != 'MSArtboardGroup') {
return NSApp.displayDialog(i18.m1);
return errorDialog(context,i18.m1);
}
var linkLayersPredicate = NSPredicate.predicateWithFormat("userInfo != nil && function(userInfo, 'valueForKeyPath:', %@).indexMain != nil", previewKey);
var indexObject = context.document.currentPage().children().filteredArrayUsingPredicate(linkLayersPredicate);
Expand All @@ -230,7 +230,7 @@ var setDialog = function (context) {
var fx = 0;

function chooseDialog() {
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.addButtonWithTitle(i18.m3);

Expand All @@ -243,11 +243,11 @@ var setDialog = function (context) {
return settingsWindow.runModal();
}
if (context.selection.length == 0) {
return NSApp.displayDialog(i18.m1);
return errorDialog(context,i18.m1);
} else {
var selection = context.selection[0];
if (selection.className() != 'MSArtboardGroup') {
return NSApp.displayDialog(i18.m1);
return errorDialog(context,i18.m1);
}
if (chooseDialog() != '1000') {
return;
Expand Down Expand Up @@ -277,7 +277,7 @@ var setFixed = function (context) {
var fx = 0;

function chooseDialog2() {
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.addButtonWithTitle(i18.m3);

Expand All @@ -291,7 +291,7 @@ var setFixed = function (context) {
}

function chooseDialog(n) {
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.addButtonWithTitle(i18.m3);
settingsWindow.setMessageText(i18.m14 + n + i18.m15);
Expand All @@ -303,11 +303,11 @@ var setFixed = function (context) {
context.command.setValue_forKey_onLayer_forPluginIdentifier(direction, "direction", selection, previewKey);
}
if (context.selection.length == 0) {
return NSApp.displayDialog(i18.m13);
return errorDialog(context,i18.m13);
} else {
var selection = context.selection[0];
if (selection.className() == 'MSArtboardGroup') {
return NSApp.displayDialog(i18.m13);
return errorDialog(context,i18.m13);
}
if (!chooseDialog2()) {
return;
Expand Down Expand Up @@ -351,18 +351,18 @@ var setBacks = function (context) {
var fx = 0;

function chooseDialog(n) {
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.addButtonWithTitle(i18.m3);
settingsWindow.setMessageText(i18.m14 + n + i18.m15);
return settingsWindow.runModal();
}
if (context.selection.length == 0) {
return NSApp.displayDialog(i18.m10);
return errorDialog(context,i18.m10);
} else {
var selection = context.selection[0];
if (selection.className() == 'MSArtboardGroup') {
return NSApp.displayDialog(i18.m10);
return errorDialog(context,i18.m10);
}
var lengthD = 0;
var saveDom = [];
Expand Down Expand Up @@ -391,18 +391,18 @@ var setNoBuild = function (context) {
var fx = 0;

function chooseDialog(n) {
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.addButtonWithTitle(i18.m3);
settingsWindow.setMessageText(i18.m14 + n + i18.m15);
return settingsWindow.runModal();
}
if (context.selection.length == 0) {
return NSApp.displayDialog(i18.m10);
return errorDialog(context,i18.m10);
} else {
var selection = context.selection[0];
if (selection.className() == 'MSArtboardGroup') {
return NSApp.displayDialog(i18.m10);
return errorDialog(context,i18.m10);
}
var lengthD = 0;
var saveDom = [];
Expand All @@ -427,7 +427,7 @@ var clearPreview = function (context) {
var i18 = _(context).commonPreview;
var domKey = ['backMain', 'fixedMain', 'dialogMain', 'indexMain', 'noBuildMain'];
if (context.selection.length == 0) {
return NSApp.displayDialog(i18.m16);
return errorDialog(context,i18.m16);
}
for (var i = 0; i < context.selection.length; i++) {
for (var k = 0; k < domKey.length; k++) {
Expand Down
4 changes: 2 additions & 2 deletions WeSketch.sketchplugin/Contents/Sketch/commonPreviewJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ var commonPreviewJson = function (context, filePath, show) {
var fxlocal = '0';

function chooseDialog() {
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.addButtonWithTitle(i18.m3);

Expand Down Expand Up @@ -406,7 +406,7 @@ var commonPreviewJson = function (context, filePath, show) {
}
}
if (!flag) {
NSApp.displayDialog(i18.m18);
errorDialog(context,i18.m18);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion WeSketch.sketchplugin/Contents/Sketch/exportColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ var onRun = function (context) {
}

} else {
NSApp.displayDialog(i18.m2);
errorDialog(context,i18.m2);
}
}
4 changes: 2 additions & 2 deletions WeSketch.sketchplugin/Contents/Sketch/exportSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function exportSlice(context) {

var selection = context.selection;
if (selection.count() == 0) {
return NSApp.displayDialog(i18.m1);
return errorDialog(context,i18.m1);
}
var scale = 0;
var parent = selection[0].parentArtboard();
Expand All @@ -34,7 +34,7 @@ function exportSlice(context) {

var imagetype = 'png';
var addressname = [];
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m2);
settingsWindow.addButtonWithTitle(i18.m3);
settingsWindow.setMessageText(i18.m4);
Expand Down
4 changes: 2 additions & 2 deletions WeSketch.sketchplugin/Contents/Sketch/flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getFlag(context, refrush) {
var colorLineB = rgb(colorLine)[2];

function deleteDialog(context) {
var settingsWindow = COSAlertWindow.new();
var settingsWindow = dialog(context);
settingsWindow.addButtonWithTitle(i18.m1);
settingsWindow.addButtonWithTitle(i18.m2);

Expand Down Expand Up @@ -293,7 +293,7 @@ function getFlag(context, refrush) {
if (context.selection.count() != 1 || refrush) {
flags = drawFunction(doc, null);
if (!refrush) {
NSApp.displayDialog(i18.m6);
errorDialog(context,i18.m6);
}
} else {
flags = drawFunction(doc, context.selection[0]);
Expand Down
4 changes: 2 additions & 2 deletions WeSketch.sketchplugin/Contents/Sketch/fontCharacters.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var fontCharacters = function (context) {
if (data.action == 'insert') {
var nowcontext = uploadContext(context);
if (nowcontext.selection.length == 0) {
return NSApp.displayDialog(i18.m1);
return errorDialog(context,i18.m1);
}
var fontfamily = [NSFont fontWithName: data.fontFamily size: 14.0];
var layer = nowcontext.selection[0];
Expand Down Expand Up @@ -69,7 +69,7 @@ var fontCharacters = function (context) {
layer.setStringValue(obj.ustr);
}
} else {
NSApp.displayDialog(i18.m1);
errorDialog(context,i18.m1);
}

windowObject.evaluateWebScript("window.location.hash = '';");
Expand Down
2 changes: 1 addition & 1 deletion WeSketch.sketchplugin/Contents/Sketch/fontReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function fontReplace(context) {
doc.showMessage(i18.m1);
return false;
} else {
userInterface = COSAlertWindow.new();
userInterface = dialog(context);
userInterface.setMessageText(i18.m2);
userInterface.addTextLabelWithValue(i18.m3 + ":");

Expand Down
3 changes: 2 additions & 1 deletion WeSketch.sketchplugin/Contents/Sketch/i18n/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"m6":", download new version automaticly?",
"m7":"Upgrade",
"m8":"Not Now",
"m9":"OK"
"m9":"OK",
"m10":"Warning"
},
"codeColor":{
"m1":"Color Copied",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "WeSketch",
"author": "Tencent WeChat",
"version": "1.3.2",
"version": "1.4.0",
"identifier": "cn.wechat",
"description": "A set of plugins for Sketch include drawing links & marks, UI Kit & Color sync, font & text replacing",
"icon": "minicon.png",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "WeSketch",
"author": "Tencent WeChat",
"version": "1.3.2",
"version": "1.4.0",
"identifier": "cn.wechat",
"description": "A set of plugins for Sketch include drawing links & marks, UI Kit & Color sync, font & text replacing",
"icon": "minicon.png",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "WeSketch",
"author": "Tencent WeChat",
"version": "1.3.2",
"version": "1.4.0",
"identifier": "cn.wechat",
"description": "A set of plugins for Sketch include drawing links & marks, UI Kit & Color sync, font & text replacing",
"icon": "minicon.png",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "WeSketch",
"author": "Tencent WeChat",
"version": "1.3.2",
"version": "1.4.0",
"identifier": "cn.wechat",
"description": "A set of plugins for Sketch include drawing links & marks, UI Kit & Color sync, font & text replacing",
"icon": "minicon.png",
Expand Down
3 changes: 2 additions & 1 deletion WeSketch.sketchplugin/Contents/Sketch/i18n/zhCN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"m6":",是否自动下载更新?",
"m7":"升级",
"m8":"暂不",
"m9":"确定"
"m9":"确定",
"m10":"警告"
},
"codeColor":{
"m1":"颜色已复制到剪贴板",
Expand Down
3 changes: 2 additions & 1 deletion WeSketch.sketchplugin/Contents/Sketch/i18n/zhTW.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"m6":",是否自動下載更新?",
"m7":"升級",
"m8":"暫不",
"m9":"確定"
"m9":"確定",
"m10":"警告"
},
"codeColor":{
"m1":"顏色已復制到剪貼板",
Expand Down
Loading

0 comments on commit a4ad4a3

Please sign in to comment.