-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; package com.sparrowwallet.sparrow.joinstr;
import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.Theme;
import com.sparrowwallet.sparrow.io.Config;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
@ -30,6 +31,9 @@ public class JoinstrController extends JoinstrFormController {
@FXML @FXML
private ToggleGroup joinstrMenu; private ToggleGroup joinstrMenu;
public JoinstrController() {
}
public void initializeView() { public void initializeView() {
joinstrMenu.selectedToggleProperty().addListener((observable, oldValue, selectedToggle) -> { joinstrMenu.selectedToggleProperty().addListener((observable, oldValue, selectedToggle) -> {
@ -51,7 +55,6 @@ public class JoinstrController extends JoinstrFormController {
} }
try { try {
if(!existing) {
URL url = AppServices.class.getResource("joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml"); URL url = AppServices.class.getResource("joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml");
if(url == null) { if(url == null) {
throw new IllegalStateException("Cannot find joinstr/" + display.toString().toLowerCase(Locale.ROOT) + ".fxml"); 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); FXMLLoader displayLoader = new FXMLLoader(url);
Node joinstrDisplay = displayLoader.load(); Node joinstrDisplay = displayLoader.load();
joinstrDisplay.setUserData(display); if(!existing) {
joinstrDisplay.setViewOrder(1);
JoinstrFormController controller = displayLoader.getController(); joinstrDisplay.setUserData(display);
JoinstrForm joinstrForm = getJoinstrForm(); joinstrDisplay.setViewOrder(1);
controller.setJoinstrForm(joinstrForm);
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) { } catch (IOException e) {
throw new IllegalStateException("Can't find pane", e); throw new IllegalStateException("Can't find pane", e);
} }
@ -83,6 +93,16 @@ public class JoinstrController extends JoinstrFormController {
joinstrMenuBox.managedProperty().bind(joinstrMenuBox.visibleProperty()); joinstrMenuBox.managedProperty().bind(joinstrMenuBox.visibleProperty());
joinstrMenuBox.visibleProperty().bind(getJoinstrForm().lockedProperty().not()); 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) { public void setStage(Stage stage) {

View file

@ -105,6 +105,12 @@ HorizontalHeaderColumn > TableColumnHeader.column-header.table-column{
-fx-background-color: rgb(159, 142, 0); -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 { .status-bar {
-fx-background-color: derive(-fx-color,-15%), -fx-body-color; -fx-background-color: derive(-fx-color,-15%), -fx-body-color;
} }

View file

@ -7,9 +7,17 @@
-fx-padding:25, 0, 0, 0; -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-padding:30, 0, 30, 0;
-fx-background-color: #164768; -fx-background-color: #1A6BA2;
-fx-text-alignment: center; -fx-text-alignment: center;
} }

View file

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