Hide perc box if not perc based price used, fix toggle button

This commit is contained in:
Manfred Karrer 2016-04-15 02:31:20 +02:00
parent bc07df2d7a
commit 261a037020
4 changed files with 9 additions and 4 deletions

View file

@ -364,7 +364,7 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
return marketPriceMargin; return marketPriceMargin;
} }
public boolean isUsePercentageBasedPrice() { public boolean getUsePercentageBasedPrice() {
return usePercentageBasedPrice; return usePercentageBasedPrice;
} }

View file

@ -938,6 +938,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
fixedPriceButton.setToggleGroup(toggleGroup); fixedPriceButton.setToggleGroup(toggleGroup);
fixedPriceButton.selectedProperty().addListener((ov, oldValue, newValue) -> { fixedPriceButton.selectedProperty().addListener((ov, oldValue, newValue) -> {
model.dataModel.setUsePercentageBasedPrice(!newValue); model.dataModel.setUsePercentageBasedPrice(!newValue);
percentagePriceButton.setSelected(!newValue);
}); });
percentagePriceButton = new ToggleButton("Percentage"); percentagePriceButton = new ToggleButton("Percentage");
@ -945,6 +946,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
percentagePriceButton.setToggleGroup(toggleGroup); percentagePriceButton.setToggleGroup(toggleGroup);
percentagePriceButton.selectedProperty().addListener((ov, oldValue, newValue) -> { percentagePriceButton.selectedProperty().addListener((ov, oldValue, newValue) -> {
model.dataModel.setUsePercentageBasedPrice(newValue); model.dataModel.setUsePercentageBasedPrice(newValue);
fixedPriceButton.setSelected(!newValue);
}); });
HBox toggleButtons = new HBox(); HBox toggleButtons = new HBox();

View file

@ -263,7 +263,7 @@ class OfferBookViewModel extends ActivatableViewModel {
Offer offer = item.getOffer(); Offer offer = item.getOffer();
Fiat price = offer.getPrice(); Fiat price = offer.getPrice();
String postFix = ""; String postFix = "";
if (offer.isUsePercentageBasedPrice()) { if (offer.getUsePercentageBasedPrice()) {
postFix = " (" + formatter.formatToPercentWithSymbol(offer.getMarketPriceMargin()) + ")"; postFix = " (" + formatter.formatToPercentWithSymbol(offer.getMarketPriceMargin()) + ")";
} }
if (showAllTradeCurrenciesProperty.get()) if (showAllTradeCurrenciesProperty.get())

View file

@ -116,6 +116,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
// private Subscription noSufficientFeeSubscription; // private Subscription noSufficientFeeSubscription;
// private MonadicBinding<Boolean> noSufficientFeeBinding; // private MonadicBinding<Boolean> noSufficientFeeBinding;
private Subscription cancelButton2StyleSubscription; private Subscription cancelButton2StyleSubscription;
private VBox priceAsPercentageInputBox;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -195,6 +196,8 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
public void initWithData(Offer offer) { public void initWithData(Offer offer) {
model.initWithData(offer); model.initWithData(offer);
priceAsPercentageInputBox.setVisible(offer.getUsePercentageBasedPrice());
if (model.getOffer().getDirection() == Offer.Direction.SELL) { if (model.getOffer().getDirection() == Offer.Direction.SELL) {
imageView.setId("image-buy-large"); imageView.setId("image-buy-large");
directionLabel.setId("direction-icon-label-buy"); directionLabel.setId("direction-icon-label-buy");
@ -211,7 +214,6 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
takeOfferButton.setText("Review offer for selling bitcoin"); takeOfferButton.setText("Review offer for selling bitcoin");
} }
boolean showComboBox = model.getPossiblePaymentAccounts().size() > 1; boolean showComboBox = model.getPossiblePaymentAccounts().size() > 1;
paymentAccountsLabel.setVisible(showComboBox); paymentAccountsLabel.setVisible(showComboBox);
paymentAccountsLabel.setManaged(showComboBox); paymentAccountsLabel.setManaged(showComboBox);
@ -850,7 +852,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
Tuple2<Label, VBox> priceAsPercentageInputBoxTuple = getTradeInputBox(priceAsPercentageValueCurrencyBox, "Distance in % from market price"); Tuple2<Label, VBox> priceAsPercentageInputBoxTuple = getTradeInputBox(priceAsPercentageValueCurrencyBox, "Distance in % from market price");
priceAsPercentageInputBoxTuple.first.setPrefWidth(200); priceAsPercentageInputBoxTuple.first.setPrefWidth(200);
VBox priceAsPercentageInputBox = priceAsPercentageInputBoxTuple.second; priceAsPercentageInputBox = priceAsPercentageInputBoxTuple.second;
priceAsPercentageTextField.setPromptText("Enter % value"); priceAsPercentageTextField.setPromptText("Enter % value");
priceAsPercentageLabel.setText("% dist."); priceAsPercentageLabel.setText("% dist.");
@ -873,6 +875,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
hBox.setSpacing(5); hBox.setSpacing(5);
hBox.setAlignment(Pos.CENTER_LEFT); hBox.setAlignment(Pos.CENTER_LEFT);
hBox.getChildren().addAll(amountInputBoxTuple.second, xLabel, priceAsPercentageInputBox); hBox.getChildren().addAll(amountInputBoxTuple.second, xLabel, priceAsPercentageInputBox);
GridPane.setRowIndex(hBox, ++gridRow); GridPane.setRowIndex(hBox, ++gridRow);
GridPane.setColumnIndex(hBox, 1); GridPane.setColumnIndex(hBox, 1);
GridPane.setMargin(hBox, new Insets(5, 10, 5, 0)); GridPane.setMargin(hBox, new Insets(5, 10, 5, 0));