change theme on all app windows

This commit is contained in:
Craig Raw 2020-12-08 17:24:22 +02:00
parent 6a1c3fa3da
commit 76820377ae
2 changed files with 24 additions and 3 deletions

View file

@ -1014,10 +1014,16 @@ public class AppController implements Initializable {
Config.get().setTheme(selectedTheme); Config.get().setTheme(selectedTheme);
} }
if(selectedTheme == Theme.DARK) { EventManager.get().post(new ThemeChangedEvent(selectedTheme));
tabs.getScene().getStylesheets().add(getClass().getResource("darktheme.css").toExternalForm()); }
@Subscribe
public void themeChanged(ThemeChangedEvent event) {
String darkCss = getClass().getResource("darktheme.css").toExternalForm();
if(event.getTheme() == Theme.DARK && !tabs.getScene().getStylesheets().contains(darkCss)) {
tabs.getScene().getStylesheets().add(darkCss);
} else { } else {
tabs.getScene().getStylesheets().remove(getClass().getResource("darktheme.css").toExternalForm()); tabs.getScene().getStylesheets().remove(darkCss);
} }
} }

View file

@ -0,0 +1,15 @@
package com.sparrowwallet.sparrow.event;
import com.sparrowwallet.sparrow.Theme;
public class ThemeChangedEvent {
private final Theme theme;
public ThemeChangedEvent(Theme theme) {
this.theme = theme;
}
public Theme getTheme() {
return theme;
}
}