This commit is contained in:
crschnick 2024-06-19 20:19:56 +00:00
parent 69a55884af
commit 7a6ebe487f
3 changed files with 22 additions and 14 deletions

View file

@ -33,6 +33,7 @@ public class ModifiedStage extends Stage {
private static void hookUpStage(Stage stage) {
applyModes(stage);
if (AppPrefs.get() != null) {
AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> {
updateStage(stage);
});
@ -40,6 +41,7 @@ public class ModifiedStage extends Stage {
updateStage(stage);
});
}
}
private static void applyModes(Stage stage) {
if (OsType.getLocal() != OsType.WINDOWS || AppPrefs.get() == null) {

View file

@ -93,8 +93,9 @@ public class PrettyImageComp extends SimpleComp {
stack.getChildren().add(storeIcon);
Consumer<String> update = val -> {
var useDark = AppPrefs.get() != null && AppPrefs.get().theme.get() != null && AppPrefs.get().theme.get().isDark();
var fixed = val != null
? FileNames.getBaseName(val) + (AppPrefs.get().theme.get().isDark() ? "-dark" : "") + "."
? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "."
+ FileNames.getExtension(val)
: null;
image.set(fixed);
@ -107,9 +108,11 @@ public class PrettyImageComp extends SimpleComp {
};
PlatformThread.sync(value).subscribe(update);
if (AppPrefs.get() != null) {
AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> {
update.accept(value.getValue());
});
}
stack.setFocusTraversable(false);
stack.setPrefWidth(width);

View file

@ -88,17 +88,20 @@ public class PrettySvgComp extends SimpleComp {
}
Consumer<String> update = val -> {
var useDark = AppPrefs.get() != null && AppPrefs.get().theme.get() != null && AppPrefs.get().theme.get().isDark();
var fixed = val != null
? FileNames.getBaseName(val) + (AppPrefs.get().theme.get().isDark() ? "-dark" : "") + "."
? FileNames.getBaseName(val) + (useDark ? "-dark" : "") + "."
+ FileNames.getExtension(val)
: null;
image.set(fixed);
};
syncValue.subscribe(update);
if (AppPrefs.get() != null) {
AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> {
update.accept(syncValue.getValue());
});
}
stack.setFocusTraversable(false);
stack.setPrefWidth(width);