Fix UI bug with dashboard view

This commit is contained in:
Manfred Karrer 2018-07-17 17:44:35 +02:00
parent e677c1a007
commit eeb9006452
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
3 changed files with 15 additions and 20 deletions

View file

@ -20,8 +20,6 @@ package bisq.desktop.components;
import bisq.core.dao.state.period.DaoPhase;
import bisq.core.locale.Res;
import bisq.common.UserThread;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.AnchorPane;
@ -83,7 +81,6 @@ public class SeparatedPhaseBars extends VBox {
widthProperty().addListener((observable, oldValue, newValue) -> {
updateWidth((double) newValue);
});
UserThread.execute(() -> updateWidth(getWidth()));
}
public void updateWidth() {
@ -117,15 +114,16 @@ public class SeparatedPhaseBars extends VBox {
}
private void updateWidth(double availableWidth) {
totalDuration = items.stream().mapToInt(SeparatedPhaseBarsItem::getDuration).sum();
// availableWidth -= vBoxLabels.getWidth();
if (availableWidth > 0 && totalDuration > 0) {
final double finalAvailableWidth = availableWidth;
items.forEach(item -> {
final double width = (double) item.duration / (double) totalDuration * finalAvailableWidth;
item.getProgressBar().setPrefWidth(width);
item.getTitleLabel().setPrefWidth(width);
});
if (availableWidth > 0) {
totalDuration = items.stream().mapToInt(SeparatedPhaseBarsItem::getDuration).sum();
if (totalDuration > 0) {
final double finalAvailableWidth = availableWidth;
items.forEach(item -> {
final double width = (double) item.duration / (double) totalDuration * finalAvailableWidth;
item.getProgressBar().setPrefWidth(width);
item.getTitleLabel().setPrefWidth(width);
});
}
}
}

View file

@ -28,8 +28,6 @@ import bisq.core.dao.state.period.DaoPhase;
import bisq.core.locale.Res;
import bisq.core.util.BSFormatter;
import bisq.common.UserThread;
import javax.inject.Inject;
import javafx.scene.control.TextField;
@ -117,8 +115,7 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
});
daoFacade.addChainHeightListener(this);
// We need to delay as otherwise the periodService has not been updated yet.
UserThread.execute(() -> onChainHeightChanged(daoFacade.getChainHeight()));
onChainHeightChanged(daoFacade.getChainHeight());
}
@Override
@ -132,7 +129,6 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
@Override
public void onChainHeightChanged(int height) {
if (height > 0) {
separatedPhaseBars.updateWidth();
phaseBarsItems.forEach(item -> {
int firstBlock = daoFacade.getFirstBlockOfPhase(height, item.getPhase());
int lastBlock = daoFacade.getLastBlockOfPhase(height, item.getPhase());
@ -148,6 +144,7 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> imple
}
item.getProgressProperty().set(progress);
});
separatedPhaseBars.updateWidth();
}
currentBlockHeightTextField.setText(String.valueOf(daoFacade.getChainHeight()));

View file

@ -519,13 +519,13 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
break;
case PROPOSAL:
case COMPENSATION_REQUEST:
final String txId = item.getTxId();
String txId = item.getTxId();
if (daoFacade.isIssuanceTx(txId)) {
awesomeIcon = AwesomeIcon.MONEY;
style = "dao-tx-type-issuance-icon";
final int issuanceBlockHeight = daoFacade.getIssuanceBlockHeight(txId);
int issuanceBlockHeight = daoFacade.getIssuanceBlockHeight(txId);
long blockTimeInSec = daoFacade.getBlockTime(issuanceBlockHeight);
final String formattedDate = bsqFormatter.formatDateTime(new Date(blockTimeInSec * 1000));
String formattedDate = bsqFormatter.formatDateTime(new Date(blockTimeInSec * 1000));
toolTipText = Res.get("dao.tx.issuance.tooltip", formattedDate);
} else {
awesomeIcon = AwesomeIcon.SHARE;