mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
always use 8 fraction digits when displaying btc amounts, use a fixed width font for numbers on osx
This commit is contained in:
parent
5ede1dd97d
commit
020ca2f312
2 changed files with 14 additions and 1 deletions
|
@ -10,16 +10,24 @@ import javafx.scene.control.ContentDisplay;
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.scene.control.TreeTableCell;
|
import javafx.scene.control.TreeTableCell;
|
||||||
import javafx.scene.layout.Region;
|
import javafx.scene.layout.Region;
|
||||||
|
import org.controlsfx.tools.Platform;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
class CoinCell extends TreeTableCell<Entry, Number> {
|
class CoinCell extends TreeTableCell<Entry, Number> {
|
||||||
|
public static final DecimalFormat TABLE_BTC_FORMAT = new DecimalFormat("0.00000000", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
|
||||||
|
|
||||||
private final Tooltip tooltip;
|
private final Tooltip tooltip;
|
||||||
|
|
||||||
public CoinCell() {
|
public CoinCell() {
|
||||||
super();
|
super();
|
||||||
tooltip = new Tooltip();
|
tooltip = new Tooltip();
|
||||||
getStyleClass().add("coin-cell");
|
getStyleClass().add("coin-cell");
|
||||||
|
if(Platform.getCurrent() == Platform.OSX) {
|
||||||
|
getStyleClass().add("number-field");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +46,8 @@ class CoinCell extends TreeTableCell<Entry, Number> {
|
||||||
BitcoinUnit unit = coinTreeTable.getBitcoinUnit();
|
BitcoinUnit unit = coinTreeTable.getBitcoinUnit();
|
||||||
|
|
||||||
String satsValue = String.format(Locale.ENGLISH, "%,d", amount.longValue());
|
String satsValue = String.format(Locale.ENGLISH, "%,d", amount.longValue());
|
||||||
final String btcValue = CoinLabel.getBTCFormat().format(amount.doubleValue() / Transaction.SATOSHIS_PER_BITCOIN);
|
DecimalFormat decimalFormat = (amount.longValue() == 0L ? CoinLabel.getBTCFormat() : TABLE_BTC_FORMAT);
|
||||||
|
final String btcValue = decimalFormat.format(amount.doubleValue() / Transaction.SATOSHIS_PER_BITCOIN);
|
||||||
|
|
||||||
if(unit.equals(BitcoinUnit.BTC)) {
|
if(unit.equals(BitcoinUnit.BTC)) {
|
||||||
tooltip.setText(satsValue + " " + BitcoinUnit.SATOSHIS.getLabel());
|
tooltip.setText(satsValue + " " + BitcoinUnit.SATOSHIS.getLabel());
|
||||||
|
|
|
@ -187,4 +187,8 @@
|
||||||
|
|
||||||
.icon-button:hover {
|
.icon-button:hover {
|
||||||
-fx-opacity: 1.0;
|
-fx-opacity: 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.number-field {
|
||||||
|
-fx-font-family: 'Helvetica Neue', 'System Regular';
|
||||||
}
|
}
|
Loading…
Reference in a new issue