From 31bd64f821e6a15fc3e3edbee40c1524105ee1b9 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 17 Jul 2023 11:17:16 +0200 Subject: [PATCH] show warning in preferences if currencies could not be retrieved from exchange rate source --- .../preferences/GeneralPreferencesController.java | 9 +++++++++ src/main/resources/com/sparrowwallet/sparrow/general.css | 4 ++++ .../com/sparrowwallet/sparrow/preferences/general.fxml | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java b/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java index 739a34c1..5fb0a750 100644 --- a/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java +++ b/src/main/java/com/sparrowwallet/sparrow/preferences/GeneralPreferencesController.java @@ -18,6 +18,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; import javafx.util.StringConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,6 +46,9 @@ public class GeneralPreferencesController extends PreferencesDetailController { @FXML private ComboBox exchangeSource; + @FXML + private Label currenciesLoadWarning; + @FXML private UnlabeledToggleSwitch loadRecentWallets; @@ -87,6 +91,9 @@ public class GeneralPreferencesController extends PreferencesDetailController { EventManager.get().post(new FeeRatesSourceChangedEvent(newValue)); }); + currenciesLoadWarning.managedProperty().bind(currenciesLoadWarning.visibleProperty()); + currenciesLoadWarning.setVisible(false); + blockExplorers.setItems(getBlockExplorerList()); blockExplorers.setConverter(new StringConverter<>() { @Override @@ -237,6 +244,8 @@ public class GeneralPreferencesController extends PreferencesDetailController { fiatCurrency.setDisable(true); } + currenciesLoadWarning.setVisible(exchangeSource.getValue() != ExchangeSource.NONE && currencies.isEmpty()); + //Always fire event regardless of previous selection to update rates EventManager.get().post(new FiatCurrencySelectedEvent(exchangeSource.getValue(), fiatCurrency.getValue())); diff --git a/src/main/resources/com/sparrowwallet/sparrow/general.css b/src/main/resources/com/sparrowwallet/sparrow/general.css index 66ac50e6..bdcaa245 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/general.css +++ b/src/main/resources/com/sparrowwallet/sparrow/general.css @@ -320,3 +320,7 @@ CellView > .text-input.text-field { -fx-background-color: -fx-control-inner-background; } +.field-warning { + -fx-text-fill: rgb(238, 210, 2); + -fx-padding: 0 0 0 12; +} diff --git a/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml b/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml index d837e883..33ba8238 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/preferences/general.fxml @@ -15,6 +15,7 @@ + @@ -60,6 +61,11 @@ +