|
8 | 8 | import com.sparrowwallet.drongo.protocol.TransactionOutput; |
9 | 9 | import com.sparrowwallet.drongo.uri.BitcoinURI; |
10 | 10 | import com.sparrowwallet.drongo.wallet.*; |
11 | | -import com.sparrowwallet.sparrow.UnitFormat; |
12 | | -import com.sparrowwallet.sparrow.AppServices; |
13 | | -import com.sparrowwallet.sparrow.EventManager; |
14 | | -import com.sparrowwallet.sparrow.Theme; |
| 11 | +import com.sparrowwallet.sparrow.*; |
15 | 12 | import com.sparrowwallet.sparrow.event.ExcludeUtxoEvent; |
16 | 13 | import com.sparrowwallet.sparrow.event.ReplaceChangeAddressEvent; |
17 | 14 | import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; |
18 | 15 | import com.sparrowwallet.sparrow.glyphfont.GlyphUtils; |
19 | 16 | import com.sparrowwallet.sparrow.io.Config; |
| 17 | +import com.sparrowwallet.sparrow.net.ExchangeSource; |
20 | 18 | import com.sparrowwallet.sparrow.wallet.OptimizationStrategy; |
21 | 19 | import javafx.beans.property.BooleanProperty; |
22 | 20 | import javafx.beans.property.ObjectProperty; |
@@ -229,6 +227,12 @@ public void update() { |
229 | 227 | getChildren().clear(); |
230 | 228 | getChildren().addAll(inputsTypePane, inputsPane, inputsLinesPane, txPane, outputsLinesPane, outputsPane); |
231 | 229 |
|
| 230 | + if(!isFinal() && walletTx.getPayments().size() > 1) { |
| 231 | + Pane totalsPane = getTotalsPane(); |
| 232 | + GridPane.setConstraints(totalsPane, 2, 0, 3, 1); |
| 233 | + getChildren().add(totalsPane); |
| 234 | + } |
| 235 | + |
232 | 236 | if(contextMenu == null) { |
233 | 237 | contextMenu = new ContextMenu(); |
234 | 238 | MenuItem menuItem = new MenuItem("Save as Image..."); |
@@ -839,6 +843,34 @@ private Pane getTransactionPane() { |
839 | 843 | return txPane; |
840 | 844 | } |
841 | 845 |
|
| 846 | + private Pane getTotalsPane() { |
| 847 | + VBox totalsBox = new VBox(); |
| 848 | + totalsBox.setPadding(new Insets(0, 0, 15, 0)); |
| 849 | + totalsBox.setAlignment(Pos.CENTER); |
| 850 | + |
| 851 | + long amount = walletTx.getPayments().stream().mapToLong(Payment::getAmount).sum(); |
| 852 | + long count = walletTx.getPayments().size(); |
| 853 | + |
| 854 | + HBox coinLabelBox = new HBox(); |
| 855 | + coinLabelBox.setAlignment(Pos.CENTER); |
| 856 | + CoinLabel totalCoinLabel = new CoinLabel(); |
| 857 | + totalCoinLabel.setValue(amount); |
| 858 | + coinLabelBox.getChildren().addAll(totalCoinLabel, new Label(" in "), new Label(Long.toString(count)), new Label(" payments")); |
| 859 | + totalsBox.getChildren().addAll(createSpacer(), coinLabelBox); |
| 860 | + |
| 861 | + CurrencyRate currencyRate = AppServices.getFiatCurrencyExchangeRate(); |
| 862 | + if(currencyRate != null && currencyRate.isAvailable() && Config.get().getExchangeSource() != ExchangeSource.NONE) { |
| 863 | + HBox fiatLabelBox = new HBox(); |
| 864 | + fiatLabelBox.setAlignment(Pos.CENTER); |
| 865 | + FiatLabel fiatLabel = new FiatLabel(); |
| 866 | + fiatLabel.set(currencyRate, amount); |
| 867 | + fiatLabelBox.getChildren().add(fiatLabel); |
| 868 | + totalsBox.getChildren().add(fiatLabelBox); |
| 869 | + } |
| 870 | + |
| 871 | + return totalsBox; |
| 872 | + } |
| 873 | + |
842 | 874 | private void saveAsImage() { |
843 | 875 | Stage window = new Stage(); |
844 | 876 | FileChooser fileChooser = new FileChooser(); |
|
0 commit comments