skpm / sketch-module-web-view

A sketch module for creating an complex UI with a webview
MIT License
289 stars 62 forks source link

When switching between themes __skpm-light / __skpm-dark class isn't set correctly #158

Closed yaelsch closed 4 years ago

yaelsch commented 4 years ago

Hi! It seems that when switching between themes the value is set to the previous theme value instead of the new value.

I looked into this code and I'm might be totally off here, but is it possible that the value should be read from the change dictionary instead of MSTheme.sharedTheme()?

sketch theme class

mathieudutour commented 4 years ago

What's the change dictionary?

But yeah IIRC you need to restart the plugin for the theme to be picked up (there isn't a listener).

yaelsch commented 4 years ago

It seems that there is a change listener:

  NSApplication.sharedApplication().addObserver_forKeyPath_options_context(
    themeObserver,
    'effectiveAppearance',
    NSKeyValueChangeNewKey,
    null
  )

And you can see the values are changing without restart, only to the opposite value.

Regarding the change dictionary, if I understand the signature of observeValueForKeyPath:ofObject:change:context the "change" parameter is supposed to hold the values of property that changed (see: https://developer.apple.com/documentation/objectivec/nsobject/1416553-observevalueforkeypath)

mathieudutour commented 4 years ago

Oh right. Well if you want to have a go at it, I'd be happy to review a PR!