Rework theme transition

This commit is contained in:
crschnick
2026-03-07 12:43:18 +00:00
parent 109fa42d51
commit fa03f320e9

View File

@@ -251,41 +251,8 @@ public class AppTheme {
TrackEvent.debug("Setting theme " + newTheme.getId() + " for scene");
// Don't animate transition in performance mode
if (AppPrefs.get() == null || AppPrefs.get().performanceMode().get()) {
newTheme.apply();
return;
}
var stage = window.getStage();
var scene = stage.getScene();
Pane root = (Pane) scene.getRoot();
Image snapshot = null;
try {
scene.snapshot(null);
} catch (Exception ex) {
// This can fail if there is no window / screen I guess?
ErrorEventFactory.fromThrowable(ex).expected().omit().handle();
return;
}
ImageView imageView = new ImageView(snapshot);
root.getChildren().add(imageView);
// Don't animate anything for performance reasons
newTheme.apply();
Platform.runLater(() -> {
// Animate!
var transition = new Timeline(
new KeyFrame(
Duration.millis(0),
new KeyValue(imageView.opacityProperty(), 1, Interpolator.EASE_OUT)),
new KeyFrame(
Duration.millis(600),
new KeyValue(imageView.opacityProperty(), 0, Interpolator.EASE_OUT)));
transition.setOnFinished(e -> {
root.getChildren().remove(imageView);
});
transition.play();
});
});
}
@@ -368,7 +335,7 @@ public class AppTheme {
"dark",
"primer",
new PrimerDark(),
() -> AppFontSizes.forOs(AppFontSizes.BASE_11, AppFontSizes.BASE_10_5, AppFontSizes.BASE_11),
() -> AppFontSizes.forOs(AppFontSizes.BASE_10_5, AppFontSizes.BASE_10_5, AppFontSizes.BASE_11),
Color.web("#0d1117"),
Color.web("#c9d1d9"),
() -> ColorHelper.withOpacity(