Skip to content
Permalink
Browse files

Improved handling for dark mode

  • Loading branch information...
Jason Burns
Jason Burns committed Oct 16, 2018
1 parent 62b7bfc commit ccec72bb22a155a554bc2e04950fabee731cdca5
@@ -40,6 +40,7 @@ To find your plugins directory...

# Changelog

* **15.7** - Improved handling for dark mode.
* **15.6** - Fix for displaying titles in versions prior to Sketch 52.
* **15.5** - The default font color for group titles will now change to white if using dark theme.
* **15.4** - Fixes for Sketch 52; shared style is now being properly applied to new titles.
@@ -118,6 +118,19 @@ function createField(value,frame) {
function createLabel(text,size,frame) {
var label = NSTextField.alloc().initWithFrame(frame);

label.setStringValue(text);
label.setFont(NSFont.systemFontOfSize(size));
label.setBezeled(false);
label.setDrawsBackground(false);
label.setEditable(false);
label.setSelectable(false);

return label;
}

function createBoldLabel(text,size,frame) {
var label = NSTextField.alloc().initWithFrame(frame);

label.setStringValue(text);
label.setFont(NSFont.boldSystemFontOfSize(size));
label.setBezeled(false);
@@ -128,13 +141,13 @@ function createLabel(text,size,frame) {
return label;
}

function createDescription(text,size,frame,alpha) {
function createDescription(text,size,frame) {
var label = NSTextField.alloc().initWithFrame(frame),
alpha = (alpha) ? alpha : 0.6;
textColor = (isUsingDarkTheme()) ? NSColor.lightGrayColor() : NSColor.darkGrayColor();

label.setStringValue(text);
label.setFont(NSFont.systemFontOfSize(size));
label.setTextColor(NSColor.colorWithCalibratedRed_green_blue_alpha(0/255,0/255,0/255,alpha));
label.setTextColor(textColor);
label.setBezeled(false);
label.setDrawsBackground(false);
label.setEditable(false);
@@ -211,6 +224,10 @@ function getTextStyleByName(context,styleName,removeStyle) {
return false;
}

function isUsingDarkTheme() {
return (NSUserDefaults.standardUserDefaults().stringForKey("AppleInterfaceStyle") == "Dark") ? true : false;
}

function renameDuplicateSymbols(symbols) {
var symbolLoop = symbols.objectEnumerator();
var symbol;
Oops, something went wrong.

0 comments on commit ccec72b

Please sign in to comment.
You can’t perform that action at this time.