mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
show tx count, set default server type
This commit is contained in:
parent
c6689228d0
commit
94da3b37b6
3 changed files with 39 additions and 19 deletions
|
@ -9,14 +9,10 @@ import com.sparrowwallet.sparrow.io.Config;
|
|||
import com.sparrowwallet.sparrow.io.FileType;
|
||||
import com.sparrowwallet.sparrow.io.IOUtils;
|
||||
import com.sparrowwallet.sparrow.io.Storage;
|
||||
import com.sparrowwallet.sparrow.net.ServerType;
|
||||
import com.sparrowwallet.sparrow.preferences.PreferenceGroup;
|
||||
import com.sparrowwallet.sparrow.preferences.PreferencesDialog;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.stage.Stage;
|
||||
import org.controlsfx.glyphfont.GlyphFontRegistry;
|
||||
|
@ -66,6 +62,10 @@ public class MainApp extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
if(Config.get().getServerType() == null) {
|
||||
Config.get().setServerType(ServerType.ELECTRUM_SERVER);
|
||||
}
|
||||
|
||||
AppServices.initialize(this);
|
||||
AppController appController = AppServices.newAppWindow(stage);
|
||||
|
||||
|
|
|
@ -4,10 +4,7 @@ import com.google.common.eventbus.Subscribe;
|
|||
import com.sparrowwallet.sparrow.AppServices;
|
||||
import com.sparrowwallet.sparrow.CurrencyRate;
|
||||
import com.sparrowwallet.sparrow.EventManager;
|
||||
import com.sparrowwallet.sparrow.control.BalanceChart;
|
||||
import com.sparrowwallet.sparrow.control.CoinLabel;
|
||||
import com.sparrowwallet.sparrow.control.FiatLabel;
|
||||
import com.sparrowwallet.sparrow.control.TransactionsTreeTable;
|
||||
import com.sparrowwallet.sparrow.control.*;
|
||||
import com.sparrowwallet.sparrow.event.*;
|
||||
import com.sparrowwallet.sparrow.net.ExchangeSource;
|
||||
import javafx.collections.ListChangeListener;
|
||||
|
@ -29,6 +26,12 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
@FXML
|
||||
private CoinLabel mempoolBalance;
|
||||
|
||||
@FXML
|
||||
private FiatLabel fiatMempoolBalance;
|
||||
|
||||
@FXML
|
||||
private CopyableLabel transactionCount;
|
||||
|
||||
@FXML
|
||||
private TransactionsTreeTable transactionsTable;
|
||||
|
||||
|
@ -47,10 +50,14 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
transactionsTable.initialize(walletTransactionsEntry);
|
||||
|
||||
balance.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||
setFiatBalance(AppServices.getFiatCurrencyExchangeRate(), newValue.longValue());
|
||||
setFiatBalance(fiatBalance, AppServices.getFiatCurrencyExchangeRate(), newValue.longValue());
|
||||
});
|
||||
balance.setValue(walletTransactionsEntry.getBalance());
|
||||
mempoolBalance.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||
setFiatBalance(fiatMempoolBalance, AppServices.getFiatCurrencyExchangeRate(), newValue.longValue());
|
||||
});
|
||||
mempoolBalance.setValue(walletTransactionsEntry.getMempoolBalance());
|
||||
setTransactionCount(walletTransactionsEntry);
|
||||
balanceChart.initialize(walletTransactionsEntry);
|
||||
|
||||
transactionsTable.getSelectionModel().getSelectedIndices().addListener((ListChangeListener<Integer>) c -> {
|
||||
|
@ -61,12 +68,19 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
});
|
||||
}
|
||||
|
||||
private void setFiatBalance(CurrencyRate currencyRate, long balance) {
|
||||
if(currencyRate != null && currencyRate.isAvailable()) {
|
||||
fiatBalance.set(currencyRate, balance);
|
||||
private void setFiatBalance(FiatLabel fiatLabel, CurrencyRate currencyRate, long balance) {
|
||||
if(currencyRate != null && currencyRate.isAvailable() && balance > 0) {
|
||||
fiatLabel.set(currencyRate, balance);
|
||||
} else {
|
||||
fiatLabel.setCurrency(null);
|
||||
fiatLabel.setBtcRate(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTransactionCount(WalletTransactionsEntry walletTransactionsEntry) {
|
||||
transactionCount.setText(walletTransactionsEntry.getChildren() != null ? Integer.toString(walletTransactionsEntry.getChildren().size()) : "0");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void walletNodesChanged(WalletNodesChangedEvent event) {
|
||||
if(event.getWallet().equals(walletForm.getWallet())) {
|
||||
|
@ -76,6 +90,7 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
balance.setValue(walletTransactionsEntry.getBalance());
|
||||
mempoolBalance.setValue(walletTransactionsEntry.getMempoolBalance());
|
||||
balanceChart.update(walletTransactionsEntry);
|
||||
setTransactionCount(walletTransactionsEntry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +106,7 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
balance.setValue(walletTransactionsEntry.getBalance());
|
||||
mempoolBalance.setValue(walletTransactionsEntry.getMempoolBalance());
|
||||
balanceChart.update(walletTransactionsEntry);
|
||||
setTransactionCount(walletTransactionsEntry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,12 +131,15 @@ public class TransactionsController extends WalletFormController implements Init
|
|||
if(event.getExchangeSource() == ExchangeSource.NONE) {
|
||||
fiatBalance.setCurrency(null);
|
||||
fiatBalance.setBtcRate(0.0);
|
||||
fiatMempoolBalance.setCurrency(null);
|
||||
fiatMempoolBalance.setBtcRate(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void exchangeRatesUpdated(ExchangeRatesUpdatedEvent event) {
|
||||
setFiatBalance(event.getCurrencyRate(), getWalletForm().getWalletTransactionsEntry().getBalance());
|
||||
setFiatBalance(fiatBalance, event.getCurrencyRate(), getWalletForm().getWalletTransactionsEntry().getBalance());
|
||||
setFiatBalance(fiatMempoolBalance, event.getCurrencyRate(), getWalletForm().getWalletTransactionsEntry().getMempoolBalance());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<?import tornadofx.control.Field?>
|
||||
<?import com.sparrowwallet.sparrow.control.CoinLabel?>
|
||||
<?import com.sparrowwallet.sparrow.control.FiatLabel?>
|
||||
<?import com.sparrowwallet.sparrow.control.CopyableLabel?>
|
||||
|
||||
<BorderPane stylesheets="@transactions.css, @wallet.css, @../general.css" styleClass="wallet-pane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.wallet.TransactionsController">
|
||||
<center>
|
||||
|
@ -32,13 +33,13 @@
|
|||
<Form GridPane.columnIndex="0" GridPane.rowIndex="0">
|
||||
<Fieldset inputGrow="SOMETIMES" text="Transactions" styleClass="header">
|
||||
<Field text="Balance:">
|
||||
<CoinLabel fx:id="balance"/>
|
||||
</Field>
|
||||
<Field text="Fiat balance:">
|
||||
<FiatLabel fx:id="fiatBalance" />
|
||||
<CoinLabel fx:id="balance"/><Region HBox.hgrow="ALWAYS"/><FiatLabel fx:id="fiatBalance" minWidth="110" />
|
||||
</Field>
|
||||
<Field text="Mempool:">
|
||||
<CoinLabel fx:id="mempoolBalance" />
|
||||
<CoinLabel fx:id="mempoolBalance" /><Region HBox.hgrow="ALWAYS"/><FiatLabel fx:id="fiatMempoolBalance" minWidth="110" />
|
||||
</Field>
|
||||
<Field text="Transactions:">
|
||||
<CopyableLabel fx:id="transactionCount" />
|
||||
</Field>
|
||||
</Fieldset>
|
||||
</Form>
|
||||
|
|
Loading…
Reference in a new issue