Skip to content

Commit

Permalink
Merge pull request #2111 from ripcurlx/ui-fixes
Browse files Browse the repository at this point in the history
Different ui bug fixes
  • Loading branch information
ManfredKarrer authored Dec 11, 2018
2 parents f0025a4 + fe53c0b commit d2341b6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
14 changes: 14 additions & 0 deletions core/src/main/java/bisq/core/trade/Contract.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package bisq.core.trade;

import bisq.core.locale.CurrencyUtil;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.OfferPayload;
import bisq.core.offer.OfferUtil;
import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.proto.CoreProtoResolver;
Expand Down Expand Up @@ -220,6 +223,17 @@ public Coin getTradeAmount() {
return Coin.valueOf(tradeAmount);
}

public Volume getTradeVolume() {
Volume volumeByAmount = getTradePrice().getVolumeByAmount(getTradeAmount());

if (getPaymentMethodId().equals(PaymentMethod.HAL_CASH_ID))
volumeByAmount = OfferUtil.getAdjustedVolumeForHalCash(volumeByAmount);
else if (CurrencyUtil.isFiatCurrency(getOfferPayload().getCurrencyCode()))
volumeByAmount = OfferUtil.getRoundedFiatVolume(volumeByAmount);

return volumeByAmount;
}

public Price getTradePrice() {
return Price.valueOf(offerPayload.getCurrencyCode(), tradePrice);
}
Expand Down
36 changes: 20 additions & 16 deletions desktop/src/main/java/bisq/desktop/main/account/AccountView.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public void initialize() {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
else
loadView(viewPath.tip());
} else {
resetSelectedTab();
}
};

Expand All @@ -115,22 +117,20 @@ public void initialize() {
};

tabChangeListener = (ov, oldValue, newValue) -> {
if (arbitratorRegistrationTab != null) {
if (arbitratorRegistrationTab != null && selectedTab != arbitratorRegistrationTab) {
navigation.navigateTo(MainView.class, AccountView.class, ArbitratorRegistrationView.class);
} else if (newValue == fiatAccountsTab) {
} else if (newValue == fiatAccountsTab && selectedTab != fiatAccountsTab) {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
} else if (newValue == altcoinAccountsTab) {
} else if (newValue == altcoinAccountsTab && selectedTab != altcoinAccountsTab) {
navigation.navigateTo(MainView.class, AccountView.class, AltCoinAccountsView.class);
} else if (newValue == notificationTab) {
} else if (newValue == notificationTab && selectedTab != notificationTab) {
navigation.navigateTo(MainView.class, AccountView.class, MobileNotificationsView.class);
} else if (newValue == passwordTab) {
} else if (newValue == passwordTab && selectedTab != passwordTab) {
navigation.navigateTo(MainView.class, AccountView.class, PasswordView.class);
} else if (newValue == seedwordsTab) {
} else if (newValue == seedwordsTab && selectedTab != seedwordsTab) {
navigation.navigateTo(MainView.class, AccountView.class, SeedWordsView.class);
} else if (newValue == backupTab) {
} else if (newValue == backupTab && selectedTab != backupTab) {
navigation.navigateTo(MainView.class, AccountView.class, BackupView.class);
} else {
navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class);
}
};

Expand Down Expand Up @@ -202,13 +202,7 @@ protected void deactivate() {
private void loadView(Class<? extends View> viewClass) {
View view = viewLoader.load(viewClass);

if (selectedTab != null && selectedTab.getContent() != null) {
if (selectedTab.getContent() instanceof ScrollPane) {
((ScrollPane) selectedTab.getContent()).setContent(null);
} else {
selectedTab.setContent(null);
}
}
resetSelectedTab();

if (view instanceof ArbitratorRegistrationView) {
if (arbitratorRegistrationTab != null) {
Expand Down Expand Up @@ -239,4 +233,14 @@ private void loadView(Class<? extends View> viewClass) {
}
root.getSelectionModel().select(selectedTab);
}

private void resetSelectedTab() {
if (selectedTab != null && selectedTab.getContent() != null) {
if (selectedTab.getContent() instanceof ScrollPane) {
((ScrollPane) selectedTab.getContent()).setContent(null);
} else {
selectedTab.setContent(null);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,11 @@ public void onFocusOutPriceAsPercentageTextField(boolean oldValue, boolean newVa
inputIsMarketBasedPrice = true;
}
marketPriceMargin.set(btcFormatter.formatRoundedDoubleWithPrecision(dataModel.getMarketPriceMargin() * 100, 2));

// We want to trigger a recalculation of the volume
UserThread.execute(() -> {
onFocusOutVolumeTextField(true, false);
});
}

void onFocusOutVolumeTextField(boolean oldValue, boolean newValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void addContent() {
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeAmount"),
formatter.formatCoinWithCode(contract.getTradeAmount()));
addConfirmationLabelLabel(gridPane, ++rowIndex, formatter.formatVolumeLabel(currencyCode, ":"),
formatter.formatVolumeWithCode(contract.getTradePrice().getVolumeByAmount(contract.getTradeAmount())));
formatter.formatVolumeWithCode(contract.getTradeVolume()));
String securityDeposit = Res.getWithColAndCap("shared.buyer") +
" " +
formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void addInfoPane() {
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
formatter.formatPrice(contract.getTradePrice()));
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeVolume"),
formatter.formatVolumeWithCode(contract.getTradePrice().getVolumeByAmount(contract.getTradeAmount())));
formatter.formatVolumeWithCode(contract.getTradeVolume()));
}

private void addCheckboxes() {
Expand Down

0 comments on commit d2341b6

Please sign in to comment.