Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different ui bug fixes #2111

Merged
merged 3 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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