-Fixes CSS when changing theme

This commit is contained in:
QcMrHyde 2025-05-19 00:14:26 -04:00
parent 891a4c3ff4
commit 916a288461
4 changed files with 51 additions and 17 deletions

View file

@ -1,6 +1,7 @@
package com.sparrowwallet.sparrow.joinstr;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.Theme;
import com.sparrowwallet.sparrow.io.Config;
import java.io.IOException;
import java.net.URL;
@ -30,6 +31,9 @@ public class JoinstrController extends JoinstrFormController {
@FXML
private ToggleGroup joinstrMenu;
public JoinstrController() {
}
public void initializeView() {
joinstrMenu.selectedToggleProperty().addListener((observable, oldValue, selectedToggle) -> {
@ -51,7 +55,6 @@ public class JoinstrController extends JoinstrFormController {
}
try {
if(!existing) {
URL url = AppServices.class.getResource("joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml");
if(url == null) {
throw new IllegalStateException("Cannot find joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml");
@ -60,15 +63,22 @@ public class JoinstrController extends JoinstrFormController {
FXMLLoader displayLoader = new FXMLLoader(url);
Node joinstrDisplay = displayLoader.load();
joinstrDisplay.setUserData(display);
joinstrDisplay.setViewOrder(1);
if(!existing) {
JoinstrFormController controller = displayLoader.getController();
JoinstrForm joinstrForm = getJoinstrForm();
controller.setJoinstrForm(joinstrForm);
joinstrDisplay.setUserData(display);
joinstrDisplay.setViewOrder(1);
joinstrPane.getChildren().add(joinstrDisplay);
}
JoinstrFormController controller = displayLoader.getController();
JoinstrForm joinstrForm = getJoinstrForm();
controller.setJoinstrForm(joinstrForm);
controller.initializeView();
joinstrPane.getChildren().add(joinstrDisplay);
}
else {
JoinstrFormController controller = displayLoader.getController();
controller.initializeView();
}
} catch (IOException e) {
throw new IllegalStateException("Can't find pane", e);
}
@ -83,6 +93,16 @@ public class JoinstrController extends JoinstrFormController {
joinstrMenuBox.managedProperty().bind(joinstrMenuBox.visibleProperty());
joinstrMenuBox.visibleProperty().bind(getJoinstrForm().lockedProperty().not());
// Set theme CSS
String darkCss = getClass().getResource("../darktheme.css").toExternalForm();
if(Config.get().getTheme() == Theme.DARK) {
if(!stage.getScene().getStylesheets().contains(darkCss)) {
stage.getScene().getStylesheets().add(darkCss);
}
} else {
stage.getScene().getStylesheets().remove(darkCss);
}
}
public void setStage(Stage stage) {

View file

@ -105,6 +105,12 @@ HorizontalHeaderColumn > TableColumnHeader.column-header.table-column{
-fx-background-color: rgb(159, 142, 0);
}
.joinstr-balance-container {
-fx-padding:30, 0, 30, 0;
-fx-background-color: #164768;
-fx-text-alignment: center;
}
.status-bar {
-fx-background-color: derive(-fx-color,-15%), -fx-body-color;
}

View file

@ -7,9 +7,17 @@
-fx-padding:25, 0, 0, 0;
}
.balance-container {
.joinstr-balance-label {
-fx-text-fill: white;
}
.joinstr-balance-label Glyph {
-fx-text-fill: white;
}
.joinstr-balance-container {
-fx-padding:30, 0, 30, 0;
-fx-background-color: #164768;
-fx-background-color: #1A6BA2;
-fx-text-alignment: center;
}

View file

@ -8,8 +8,8 @@
<?import com.sparrowwallet.sparrow.joinstr.JoinstrDisplay?>
<?import org.controlsfx.glyphfont.Glyph?>
<BorderPane stylesheets="@joinstr.css, @../general.css" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.sparrowwallet.sparrow.joinstr.JoinstrController"
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="200" minWidth="350" prefHeight="770.0" prefWidth="1070.0">
<BorderPane stylesheets="@joinstr.css, @../wallet/wallet.css" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="com.sparrowwallet.sparrow.joinstr.JoinstrController"
maxHeight="-Infinity" maxWidth="-Infinity" prefHeight="770.0" prefWidth="1070.0">
<left>
<VBox fx:id="joinstrMenuBox" styleClass="list-menu">
<Pane styleClass="spacerV50" />
@ -39,11 +39,11 @@
<VBox>
<Pane styleClass="spacerV25" />
<HBox>
<VBox maxWidth="Infinity" HBox.hgrow="ALWAYS" styleClass="balance-container">
<Label fx:id="joinstrBalanceTitle" styleClass="balance-label">
<VBox maxWidth="Infinity" HBox.hgrow="ALWAYS" styleClass="joinstr-balance-container">
<Label fx:id="joinstrBalanceTitle" styleClass="joinstr-balance-label">
Current balance:
</Label>
<Label fx:id="joinstrBalanceValue" styleClass="balance-label">
<Label fx:id="joinstrBalanceValue" styleClass="joinstr-balance-label">
0.00000001
<graphic>
<Glyph fontFamily="FontAwesome" icon="BTC" fontSize="20" />
@ -51,7 +51,7 @@
</Label>
</VBox>
</HBox>
<Pane styleClass="spacer25" />
<Pane styleClass="spacerV25" />
</VBox>
</VBox>
</left>