Update 2 to new trade process UI

This commit is contained in:
Manfred Karrer 2014-09-24 00:58:25 +02:00
parent f80758ca34
commit 1e692ec8c4
21 changed files with 215 additions and 157 deletions

View file

@ -85,12 +85,6 @@ lower gradient color on tab: dddddd
-fx-fill: -fx-accent; -fx-fill: -fx-accent;
} }
#nav-alert-button {
-fx-background-color: transparent;
-fx-cursor: hand;
-fx-border-style: none;
}
#nav-button-label { #nav-button-label {
-fx-font-size: 10; -fx-font-size: 10;
} }
@ -99,7 +93,11 @@ lower gradient color on tab: dddddd
-fx-font-weight: bold; -fx-font-weight: bold;
-fx-alignment: center; -fx-alignment: center;
} }
#nav-alert-label {
-fx-font-weight: bold;
-fx-font-size: 11;
-fx-text-fill: white;
}
.text-field:readonly { .text-field:readonly {
-fx-text-fill: #000000; -fx-text-fill: #000000;
-fx-background-color: #FAFAFA; -fx-background-color: #FAFAFA;
@ -302,10 +300,6 @@ textfield */
-fx-background-insets: 0 0 0 0,0,1; -fx-background-insets: 0 0 0 0,0,1;
} }
#content-pane-label {
-fx-font-size: 14;
-fx-text-fill: black;
}
#info-icon-label { #info-icon-label {
-fx-font-size:16; -fx-font-size:16;
-fx-text-fill: #333000; -fx-text-fill: #333000;
@ -356,22 +350,22 @@ textfield */
#wizard-title-active { #wizard-title-active {
-fx-font-weight: bold; -fx-font-weight: bold;
-fx-font-size: 16; -fx-font-size: 16;
-fx-text-fill: black; -fx-text-fill: #333333;
} }
#wizard-title-completed { #wizard-title-completed {
-fx-font-weight: bold; -fx-font-weight: bold;
-fx-font-size: 16; -fx-font-size: 16;
-fx-text-fill: black; -fx-text-fill: #333333;
} }
#wizard-sub-title-deactivated { #wizard-sub-title-deactivated {
-fx-text-fill: #CCCCCC; -fx-text-fill: #CCCCCC;
} }
#wizard-sub-title-active { #wizard-sub-title-active {
-fx-text-fill: black; -fx-text-fill: #333333;
} }
#wizard-sub-title-completed { #wizard-sub-title-completed {
-fx-text-fill: black; -fx-text-fill: #333333;
} }
#wizard-item-background-deactivated { #wizard-item-background-deactivated {
@ -417,7 +411,7 @@ textfield */
#wizard-title-active { #wizard-title-active {
-fx-font-weight: bold; -fx-font-weight: bold;
-fx-font-size: 16; -fx-font-size: 16;
-fx-text-fill: black; -fx-text-fill: #333333;
} }
#wizard-title-selected { #wizard-title-selected {
-fx-font-weight: bold; -fx-font-weight: bold;

View file

@ -42,8 +42,8 @@ public class BalanceTextField extends AnchorPane {
private final Tooltip progressIndicatorTooltip; private final Tooltip progressIndicatorTooltip;
private final ConfidenceProgressIndicator progressIndicator; private final ConfidenceProgressIndicator progressIndicator;
private final Effect fundedEffect = new DropShadow(BlurType.GAUSSIAN, Color.GREEN, 4, 0.0, 0, 0); private final Effect fundedEffect = new DropShadow(BlurType.THREE_PASS_BOX, Color.GREEN, 4, 0.0, 0, 0);
private final Effect notFundedEffect = new DropShadow(BlurType.GAUSSIAN, Color.ORANGERED, 4, 0.0, 0, 0); private final Effect notFundedEffect = new DropShadow(BlurType.THREE_PASS_BOX, Color.ORANGERED, 4, 0.0, 0, 0);
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
public class InputTextField extends TextField { public class InputTextField extends TextField {
private static final Logger log = LoggerFactory.getLogger(InputTextField.class); private static final Logger log = LoggerFactory.getLogger(InputTextField.class);
private final Effect invalidEffect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.0, 0, 0); private final Effect invalidEffect = new DropShadow(BlurType.THREE_PASS_BOX, Color.RED, 4, 0.0, 0, 0);
private final ObjectProperty<InputValidator.ValidationResult> validationResult = new SimpleObjectProperty<> private final ObjectProperty<InputValidator.ValidationResult> validationResult = new SimpleObjectProperty<>
(new InputValidator.ValidationResult(true)); (new InputValidator.ValidationResult(true));

View file

@ -55,7 +55,7 @@ public class ValidatedTextField extends TextField {
private final IntegerProperty minLength; private final IntegerProperty minLength;
private final IntegerProperty maxLength; private final IntegerProperty maxLength;
private Effect invalidEffect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.0, 0, 0); private Effect invalidEffect = new DropShadow(BlurType.THREE_PASS_BOX, Color.RED, 4, 0.0, 0, 0);
public ValidatedTextField() { public ValidatedTextField() {
super(); super();

View file

@ -71,6 +71,10 @@ public class ProcessStepBar<T> extends Control {
((ProcessStepBarSkin) getSkin()).setSelectedIndex(selectedIndex); ((ProcessStepBarSkin) getSkin()).setSelectedIndex(selectedIndex);
} }
public void reset() {
if (getSkin() != null)
((ProcessStepBarSkin) getSkin()).reset();
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Getters // Getters
@ -86,4 +90,6 @@ public class ProcessStepBar<T> extends Control {
public IntegerProperty selectedIndexProperty() { public IntegerProperty selectedIndexProperty() {
return selectedIndex; return selectedIndex;
} }
} }

View file

@ -60,6 +60,19 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
} }
///////////////////////////////////////////////////////////////////////////////////////////
// Methods
///////////////////////////////////////////////////////////////////////////////////////////
public void reset() {
prevLabelWithBorder = null;
for (int i = 0; i < labelWithBorders.size(); i++) {
currentLabelWithBorder = labelWithBorders.get(i);
currentLabelWithBorder.open();
}
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Setters // Setters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -79,22 +92,21 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
i++; i++;
} }
currentLabelWithBorder.select(); currentLabelWithBorder.current();
} }
} }
public void setSelectedIndex(int index) { public void setSelectedIndex(int index) {
this.index = index; this.index = index;
if (index < labelWithBorders.size()) { if (index < labelWithBorders.size()) {
for (int i = 0; i <= index; i++) { for (int i = 0; i <= index; i++) {
if (prevLabelWithBorder != null) if (prevLabelWithBorder != null)
prevLabelWithBorder.deSelect(); prevLabelWithBorder.past();
currentLabelWithBorder = labelWithBorders.get(i); currentLabelWithBorder = labelWithBorders.get(i);
currentLabelWithBorder.select(); currentLabelWithBorder.current();
prevLabelWithBorder = currentLabelWithBorder; prevLabelWithBorder = currentLabelWithBorder;
} }
@ -121,7 +133,6 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
} }
} }
public static class LabelWithBorder extends Label { public static class LabelWithBorder extends Label {
final double borderWidth = 1; final double borderWidth = 1;
private final double arrowWidth = 10; private final double arrowWidth = 10;
@ -144,13 +155,18 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
this.setShape(createButtonShape()); this.setShape(createButtonShape());
open();
}
public void open() {
log.debug("select " + processStepItem.getLabel());
BorderStroke borderStroke = new BorderStroke(Colors.LIGHT_GREY, BorderStrokeStyle.SOLID, null, BorderStroke borderStroke = new BorderStroke(Colors.LIGHT_GREY, BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY); new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
this.setBorder(new Border(borderStroke)); this.setBorder(new Border(borderStroke));
setTextFill(Colors.LIGHT_GREY); setTextFill(Colors.LIGHT_GREY);
} }
public void select() { public void current() {
log.debug("select " + processStepItem.getLabel()); log.debug("select " + processStepItem.getLabel());
BorderStroke borderStroke = new BorderStroke(Colors.BLUE, BorderStrokeStyle.SOLID, null, BorderStroke borderStroke = new BorderStroke(Colors.BLUE, BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY); new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
@ -158,12 +174,12 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
setTextFill(Colors.BLUE); setTextFill(Colors.BLUE);
} }
public void deSelect() { public void past() {
log.debug("deSelect " + processStepItem.getLabel()); log.debug("deSelect " + processStepItem.getLabel());
BorderStroke borderStroke = new BorderStroke(Colors.GREEN, BorderStrokeStyle.SOLID, null, BorderStroke borderStroke = new BorderStroke(Colors.DARK_GREY, BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY); new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
this.setBorder(new Border(borderStroke)); this.setBorder(new Border(borderStroke));
setTextFill(Colors.GREEN); setTextFill(Colors.DARK_GREY);
} }
public double getArrowWidth() { public double getArrowWidth() {

View file

@ -25,6 +25,7 @@ import io.bitsquare.gui.util.Profiler;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.BootstrapListener; import io.bitsquare.msg.listeners.BootstrapListener;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.TradeManager; import io.bitsquare.trade.TradeManager;
import io.bitsquare.user.User; import io.bitsquare.user.User;
@ -34,10 +35,13 @@ import com.google.inject.Inject;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty; import javafx.beans.property.DoubleProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -58,9 +62,8 @@ class MainModel extends UIModel {
final BooleanProperty backendInited = new SimpleBooleanProperty(); final BooleanProperty backendInited = new SimpleBooleanProperty();
final DoubleProperty networkSyncProgress = new SimpleDoubleProperty(); final DoubleProperty networkSyncProgress = new SimpleDoubleProperty();
final BooleanProperty networkSyncComplete = new SimpleBooleanProperty(); final BooleanProperty networkSyncComplete = new SimpleBooleanProperty();
final BooleanProperty takeOfferRequested = new SimpleBooleanProperty();
final ObjectProperty<Coin> balance = new SimpleObjectProperty<>(); final ObjectProperty<Coin> balance = new SimpleObjectProperty<>();
final IntegerProperty numPendingTrades = new SimpleIntegerProperty(0);
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -171,11 +174,16 @@ class MainModel extends UIModel {
} }
}); });
tradeManager.addTakeOfferRequestListener((offerId, sender) -> takeOfferRequested.set(true)); tradeManager.getTrades().addListener((MapChangeListener<String, Trade>) change -> updateNumPendingTrades());
updateNumPendingTrades();
backendInited.set(true); backendInited.set(true);
} }
private void updateNumPendingTrades() {
numPendingTrades.set(tradeManager.getTrades().size());
}
private void updateBalance(Coin balance) { private void updateBalance(Coin balance) {
this.balance.set(balance); this.balance.set(balance);
} }

View file

@ -24,8 +24,10 @@ import io.bitsquare.gui.util.BSFormatter;
import com.google.inject.Inject; import com.google.inject.Inject;
import javafx.beans.property.BooleanProperty; import javafx.beans.property.BooleanProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty; import javafx.beans.property.StringProperty;
import javafx.collections.ListChangeListener; import javafx.collections.ListChangeListener;
@ -44,7 +46,7 @@ class MainPM extends PresentationModel<MainModel> {
final BooleanProperty bankAccountsComboBoxDisable = new SimpleBooleanProperty(); final BooleanProperty bankAccountsComboBoxDisable = new SimpleBooleanProperty();
final StringProperty splashScreenInfoText = new SimpleStringProperty(); final StringProperty splashScreenInfoText = new SimpleStringProperty();
final BooleanProperty networkSyncComplete = new SimpleBooleanProperty(); final BooleanProperty networkSyncComplete = new SimpleBooleanProperty();
final BooleanProperty takeOfferRequested = new SimpleBooleanProperty(); final IntegerProperty numPendingTrades = new SimpleIntegerProperty();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -68,7 +70,7 @@ class MainPM extends PresentationModel<MainModel> {
backendInited.bind(model.backendInited); backendInited.bind(model.backendInited);
networkSyncComplete.bind(model.networkSyncComplete); networkSyncComplete.bind(model.networkSyncComplete);
takeOfferRequested.bind(model.takeOfferRequested); numPendingTrades.bind(model.numPendingTrades);
model.networkSyncProgress.addListener((ov, oldValue, newValue) -> { model.networkSyncProgress.addListener((ov, oldValue, newValue) -> {
if ((double) newValue > 0) if ((double) newValue > 0)

View file

@ -42,8 +42,10 @@ import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.*; import javafx.scene.*;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.effect.*;
import javafx.scene.image.*; import javafx.scene.image.*;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.paint.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -64,6 +66,7 @@ public class MainViewCB extends ViewCB<MainPM> {
private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton, private ToggleButton buyButton, sellButton, homeButton, msgButton, ordersButton, fundsButton, settingsButton,
accountButton; accountButton;
private Pane ordersButtonButtonPane; private Pane ordersButtonButtonPane;
private Label numPendingTradesLabel;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -179,25 +182,44 @@ public class MainViewCB extends ViewCB<MainPM> {
addMainNavigation(); addMainNavigation();
} }
private void applyPendingTradesInfoIcon(int numPendingTrades) {
log.debug("numPendingTrades " + numPendingTrades);
if (numPendingTrades > 0) {
if (ordersButtonButtonPane.getChildren().size() == 1) {
ImageView icon = new ImageView();
icon.setLayoutX(0.5);
icon.setId("image-alert-round");
numPendingTradesLabel = new Label(String.valueOf(numPendingTrades));
numPendingTradesLabel.relocate(5, 1);
numPendingTradesLabel.setId("nav-alert-label");
Pane alert = new Pane();
alert.relocate(30, 9);
alert.setMouseTransparent(true);
alert.setEffect(new DropShadow(4, 1, 2, Color.GREY));
alert.getChildren().addAll(icon, numPendingTradesLabel);
ordersButtonButtonPane.getChildren().add(alert);
AWTSystemTray.setAlertIcon();
}
else {
numPendingTradesLabel.setText(String.valueOf(numPendingTrades));
}
}
else {
if (ordersButtonButtonPane.getChildren().size() > 1)
ordersButtonButtonPane.getChildren().remove(1);
AWTSystemTray.setIcon();
}
}
private void onMainNavigationAdded() { private void onMainNavigationAdded() {
Profiler.printMsgWithTime("MainController.ondMainNavigationAdded"); Profiler.printMsgWithTime("MainController.ondMainNavigationAdded");
presentationModel.takeOfferRequested.addListener((ov, olaValue, newValue) -> { presentationModel.numPendingTrades.addListener((ov, olaValue, newValue) -> applyPendingTradesInfoIcon((int)
ImageView icon = new ImageView(); newValue));
icon.setId("image-alert-round"); applyPendingTradesInfoIcon(presentationModel.numPendingTrades.get());
final Button alertButton = new Button("", icon);
alertButton.setId("nav-alert-button");
alertButton.relocate(30, 9);
alertButton.setOnAction((e) ->
navigation.navigationTo(Navigation.Item.MAIN,
Navigation.Item.ORDERS,
Navigation.Item.PENDING_TRADES));
Tooltip.install(alertButton, new Tooltip("Your offer has been accepted"));
ordersButtonButtonPane.getChildren().add(alertButton);
AWTSystemTray.setAlertIcon();
});
navigation.navigateToLastStoredItem(); navigation.navigateToLastStoredItem();
onContentAdded(); onContentAdded();
} }

View file

@ -109,6 +109,7 @@ public class AccountSetupViewCB extends ViewCB implements MultiStepNavigation {
// triggers navigationTo // triggers navigationTo
childController = seedWords.show(); childController = seedWords.show();
} }
@Override @Override
@ -230,6 +231,7 @@ class WizardItem extends HBox {
imageView.setId("image-arrow-blue"); imageView.setId("image-arrow-blue");
titleLabel.setId("wizard-title-active"); titleLabel.setId("wizard-title-active");
subTitleLabel.setId("wizard-sub-title-active"); subTitleLabel.setId("wizard-sub-title-active");
return childController; return childController;
} }

View file

@ -35,6 +35,8 @@ import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.MapChangeListener; import javafx.collections.MapChangeListener;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
@ -55,6 +57,7 @@ public class PendingTradesModel extends UIModel {
final ObjectProperty<Trade.State> tradeState = new SimpleObjectProperty<>(); final ObjectProperty<Trade.State> tradeState = new SimpleObjectProperty<>();
final ObjectProperty<Throwable> fault = new SimpleObjectProperty<>(); final ObjectProperty<Throwable> fault = new SimpleObjectProperty<>();
final StringProperty txId = new SimpleStringProperty();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -121,6 +124,9 @@ public class PendingTradesModel extends UIModel {
currentItem = item; currentItem = item;
isOfferer = tradeManager.isTradeMyOffer(currentItem.getTrade()); isOfferer = tradeManager.isTradeMyOffer(currentItem.getTrade());
// we want to re-trigger a change if the state is the same but different trades
tradeState.set(null);
selectedIndex.set(pendingTrades.indexOf(item)); selectedIndex.set(pendingTrades.indexOf(item));
Trade currentTrade = currentItem.getTrade(); Trade currentTrade = currentItem.getTrade();
if (currentTrade.getDepositTx() != null) { if (currentTrade.getDepositTx() != null) {
@ -135,6 +141,11 @@ public class PendingTradesModel extends UIModel {
.getHashAsString())); .getHashAsString()));
} }
if (currentItem.getTrade().getDepositTx() != null)
txId.set(currentItem.getTrade().getDepositTx().getHashAsString());
else
txId.set("");
currentTrade.stateProperty().addListener((ov, oldValue, newValue) -> tradeState.set(newValue)); currentTrade.stateProperty().addListener((ov, oldValue, newValue) -> tradeState.set(newValue));
tradeState.set(currentTrade.stateProperty().get()); tradeState.set(currentTrade.stateProperty().get());
@ -172,13 +183,6 @@ public class PendingTradesModel extends UIModel {
return currentItem.getTrade(); return currentItem.getTrade();
} }
public String getTxID() {
if (currentItem.getTrade().getDepositTx() != null)
return currentItem.getTrade().getDepositTx().getHashAsString();
else
return null;
}
public Coin getTotalFees() { public Coin getTotalFees() {
Coin tradeFee = isOfferer() ? FeePolicy.CREATE_OFFER_FEE : FeePolicy.TAKE_OFFER_FEE; Coin tradeFee = isOfferer() ? FeePolicy.CREATE_OFFER_FEE : FeePolicy.TAKE_OFFER_FEE;
return tradeFee.add(FeePolicy.TX_FEE); return tradeFee.add(FeePolicy.TX_FEE);
@ -193,7 +197,9 @@ public class PendingTradesModel extends UIModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void updateConfidence(TransactionConfidence confidence) { private void updateConfidence(TransactionConfidence confidence) {
if (confidence != null && confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING) if (confidence != null &&
confidence.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING
&& currentItem.getTrade().getState() == Trade.State.DEPOSIT_PUBLISHED)
currentItem.getTrade().setState(Trade.State.DEPOSIT_CONFIRMED); currentItem.getTrade().setState(Trade.State.DEPOSIT_CONFIRMED);
} }

View file

@ -63,6 +63,7 @@ public class PendingTradesPM extends PresentationModel<PendingTradesModel> {
final ObjectProperty<State> state = new SimpleObjectProperty<>(); final ObjectProperty<State> state = new SimpleObjectProperty<>();
final ObjectProperty<Trade.State> tradeState = new SimpleObjectProperty<>(); final ObjectProperty<Trade.State> tradeState = new SimpleObjectProperty<>();
final ObjectProperty<Throwable> fault = new SimpleObjectProperty<>(); final ObjectProperty<Throwable> fault = new SimpleObjectProperty<>();
final StringProperty txId = new SimpleStringProperty();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -83,12 +84,12 @@ public class PendingTradesPM extends PresentationModel<PendingTradesModel> {
@Override @Override
public void initialize() { public void initialize() {
selectedIndex.bind(model.selectedIndex); selectedIndex.bind(model.selectedIndex);
tradeState.addListener((ov, oldValue, newValue) -> { txId.bind(model.txId);
model.tradeState.addListener((ov, oldValue, newValue) -> {
updateState(); updateState();
}); });
fault.bind(model.fault); fault.bind(model.fault);
super.initialize(); super.initialize();
} }
@ -143,10 +144,6 @@ public class PendingTradesPM extends PresentationModel<PendingTradesModel> {
return model.isOfferer(); return model.isOfferer();
} }
public String getTxID() {
return model.getTxID();
}
public WalletFacade getWalletFacade() { public WalletFacade getWalletFacade() {
return model.getWalletFacade(); return model.getWalletFacade();
} }
@ -245,6 +242,9 @@ public class PendingTradesPM extends PresentationModel<PendingTradesModel> {
break; break;
} }
} }
else {
state.set(null);
}
} }
} }

View file

@ -140,7 +140,7 @@
</GridPane.margin> </GridPane.margin>
</TitledGroupBg> </TitledGroupBg>
<Label fx:id="btcLabel" text="You have bought:" GridPane.rowIndex="5" visible="false"> <Label fx:id="btcLabel" GridPane.rowIndex="5" visible="false">
<GridPane.margin> <GridPane.margin>
<Insets top="60.0"/> <Insets top="60.0"/>
</GridPane.margin> </GridPane.margin>
@ -152,7 +152,7 @@
</GridPane.margin> </GridPane.margin>
</TextField> </TextField>
<Label fx:id="fiatLabel" text="You have paid:" GridPane.rowIndex="6" visible="false"/> <Label fx:id="fiatLabel" GridPane.rowIndex="6" visible="false"/>
<TextField fx:id="fiatTextField" GridPane.rowIndex="6" GridPane.columnIndex="1" editable="false" visible="false"/> <TextField fx:id="fiatTextField" GridPane.rowIndex="6" GridPane.columnIndex="1" editable="false" visible="false"/>
<Label fx:id="feesLabel" text="Total fees paid:" GridPane.rowIndex="7" visible="false"/> <Label fx:id="feesLabel" text="Total fees paid:" GridPane.rowIndex="7" visible="false"/>

View file

@ -127,10 +127,31 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
super.activate(); super.activate();
if (!presentationModel.getPendingTrades().isEmpty()) { if (!presentationModel.getPendingTrades().isEmpty()) {
titledGroupBg.setVisible(true);
processBar.setVisible(true);
statusLabel.setVisible(true);
statusTextField.setVisible(true);
txIdLabel.setVisible(true);
txIdTextField.setVisible(true);
infoDisplay.setVisible(true);
if (presentationModel.isOfferer()) if (presentationModel.isOfferer())
setupScreenForOfferer(); setupScreenForOfferer();
else else
setupScreenForTaker(); setupScreenForTaker();
presentationModel.txId.addListener((ov, oldValue, newValue) ->
txIdTextField.setup(presentationModel.getWalletFacade(), newValue));
txIdTextField.setup(presentationModel.getWalletFacade(), presentationModel.txId.get());
}
else {
titledGroupBg.setVisible(false);
processBar.setVisible(false);
statusLabel.setVisible(false);
statusTextField.setVisible(false);
txIdLabel.setVisible(false);
txIdTextField.setVisible(false);
infoDisplay.setVisible(false);
} }
} }
@ -185,15 +206,6 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
private void setupScreenForOfferer() { private void setupScreenForOfferer() {
log.debug("setupScreenForOfferer"); log.debug("setupScreenForOfferer");
titledGroupBg.setVisible(true);
processBar.setVisible(true);
statusLabel.setVisible(true);
statusTextField.setVisible(true);
txIdLabel.setVisible(true);
txIdTextField.setVisible(true);
infoDisplay.setVisible(true);
log.debug("setupScreenForTaker");
if (processBar.getProcessStepItems() == null) { if (processBar.getProcessStepItems() == null) {
List<ProcessStepItem> items = new ArrayList<>(); List<ProcessStepItem> items = new ArrayList<>();
items.add(new ProcessStepItem("Wait for block chain confirmation")); items.add(new ProcessStepItem("Wait for block chain confirmation"));
@ -203,14 +215,11 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
processBar.setProcessStepItems(items); processBar.setProcessStepItems(items);
} }
txIdTextField.setup(presentationModel.getWalletFacade(), presentationModel.getTxID());
presentationModel.state.addListener((ov, oldValue, newValue) -> applyOffererState(newValue)); presentationModel.state.addListener((ov, oldValue, newValue) -> applyOffererState(newValue));
applyOffererState(presentationModel.state.get()); applyOffererState(presentationModel.state.get());
} }
private void applyOffererState(PendingTradesPM.State state) { private void applyOffererState(PendingTradesPM.State state) {
if (state != null) {
paymentsGroupBg.setVisible(false); paymentsGroupBg.setVisible(false);
paymentMethodLabel.setVisible(false); paymentMethodLabel.setVisible(false);
holderNameLabel.setVisible(false); holderNameLabel.setVisible(false);
@ -234,7 +243,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
collateralTextField.setVisible(false); collateralTextField.setVisible(false);
summaryInfoDisplay.setVisible(false); summaryInfoDisplay.setVisible(false);
if (state != null) {
switch (state) { switch (state) {
case OFFERER_BUYER_WAIT_TX_CONF: case OFFERER_BUYER_WAIT_TX_CONF:
processBar.setSelectedIndex(0); processBar.setSelectedIndex(0);
@ -300,6 +309,8 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
collateralTextField.setVisible(true); collateralTextField.setVisible(true);
summaryInfoDisplay.setVisible(true); summaryInfoDisplay.setVisible(true);
btcLabel.setText("You have bought:");
fiatLabel.setText("You have paid:");
btcTextField.setText(presentationModel.getTradeVolume()); btcTextField.setText(presentationModel.getTradeVolume());
fiatTextField.setText(presentationModel.getFiatVolume()); fiatTextField.setText(presentationModel.getFiatVolume());
feesTextField.setText(presentationModel.getTotalFees()); feesTextField.setText(presentationModel.getTotalFees());
@ -308,16 +319,30 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
break; break;
} }
} }
else {
processBar.reset();
}
} }
private void setupScreenForTaker() { private void setupScreenForTaker() {
titledGroupBg.setVisible(true); log.debug("setupScreenForTaker");
processBar.setVisible(true); if (processBar.getProcessStepItems() == null) {
statusLabel.setVisible(true); List<ProcessStepItem> items = new ArrayList<>();
statusTextField.setVisible(true); items.add(new ProcessStepItem("Wait for block chain confirmation"));
txIdLabel.setVisible(true); items.add(new ProcessStepItem("Wait for payment started"));
txIdTextField.setVisible(true); items.add(new ProcessStepItem("Confirm payment"));
infoDisplay.setVisible(true); items.add(new ProcessStepItem("Trade successful completed"));
processBar.setProcessStepItems(items);
}
presentationModel.state.addListener((ov, oldValue, newValue) -> applyTakerState(newValue));
applyTakerState(presentationModel.state.get());
}
private void applyTakerState(PendingTradesPM.State state) {
log.debug("#### state " + state);
confirmPaymentReceiptButton.setVisible(false);
summaryGroupBg.setVisible(false); summaryGroupBg.setVisible(false);
btcLabel.setVisible(false); btcLabel.setVisible(false);
@ -330,26 +355,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
collateralTextField.setVisible(false); collateralTextField.setVisible(false);
summaryInfoDisplay.setVisible(false); summaryInfoDisplay.setVisible(false);
log.debug("setupScreenForTaker");
if (processBar.getProcessStepItems() == null) {
List<ProcessStepItem> items = new ArrayList<>();
items.add(new ProcessStepItem("Wait for block chain confirmation"));
items.add(new ProcessStepItem("Wait for payment started"));
items.add(new ProcessStepItem("Confirm payment"));
items.add(new ProcessStepItem("Trade successful completed"));
processBar.setProcessStepItems(items);
}
txIdTextField.setup(presentationModel.getWalletFacade(), presentationModel.getTxID());
presentationModel.state.addListener((ov, oldValue, newValue) -> applyTakerState(newValue));
applyTakerState(presentationModel.state.get());
}
private void applyTakerState(PendingTradesPM.State state) {
log.debug("#### state " + state);
if (state != null) { if (state != null) {
confirmPaymentReceiptButton.setVisible(false);
switch (state) { switch (state) {
case TAKER_SELLER_WAIT_TX_CONF: case TAKER_SELLER_WAIT_TX_CONF:
processBar.setSelectedIndex(0); processBar.setSelectedIndex(0);
@ -392,6 +398,8 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
collateralTextField.setVisible(true); collateralTextField.setVisible(true);
summaryInfoDisplay.setVisible(true); summaryInfoDisplay.setVisible(true);
btcLabel.setText("You have sold:");
fiatLabel.setText("You have received:");
btcTextField.setText(presentationModel.getTradeVolume()); btcTextField.setText(presentationModel.getTradeVolume());
fiatTextField.setText(presentationModel.getFiatVolume()); fiatTextField.setText(presentationModel.getFiatVolume());
feesTextField.setText(presentationModel.getTotalFees()); feesTextField.setText(presentationModel.getTotalFees());
@ -400,6 +408,9 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
break; break;
} }
} }
else {
processBar.reset();
}
} }

View file

@ -69,11 +69,12 @@ public class BSFormatter {
// no way to remove grouping separator). It seems to be not optimal for user input formatting. // no way to remove grouping separator). It seems to be not optimal for user input formatting.
private static CoinFormat coinFormat = CoinFormat.BTC.repeatOptionalDecimals(2, 1); private static CoinFormat coinFormat = CoinFormat.BTC.repeatOptionalDecimals(2, 1);
// format is like: 1,00 never more then 2 decimals
private static final CoinFormat fiatFormat = CoinFormat.FIAT.repeatOptionalDecimals(0, 0);
private static String currencyCode = Currency.getInstance(Locale.getDefault()).getCurrencyCode(); private static String currencyCode = Currency.getInstance(Locale.getDefault()).getCurrencyCode();
// format is like: 1,00 never more then 2 decimals
private static final CoinFormat fiatFormat = CoinFormat.FIAT.repeatOptionalDecimals(0, 0).code(0, currencyCode);
@Inject @Inject
public BSFormatter(User user) { public BSFormatter(User user) {
if (user.currentBankAccountProperty().get() == null) if (user.currentBankAccountProperty().get() == null)
@ -115,6 +116,7 @@ public class BSFormatter {
public static void setFiatCurrencyCode(String currencyCode) { public static void setFiatCurrencyCode(String currencyCode) {
BSFormatter.currencyCode = currencyCode; BSFormatter.currencyCode = currencyCode;
fiatFormat.code(0, currencyCode);
} }

View file

@ -29,7 +29,7 @@ import javafx.scene.paint.*;
//TODO to be removed //TODO to be removed
@Deprecated @Deprecated
public class BitSquareValidator { public class BitSquareValidator {
private static final Effect invalidEffect = new DropShadow(BlurType.GAUSSIAN, Color.RED, 4, 0.0, 0, 0); private static final Effect invalidEffect = new DropShadow(BlurType.THREE_PASS_BOX, Color.RED, 4, 0.0, 0, 0);
private static final String invalidStyle = "-fx-border-color: red"; private static final String invalidStyle = "-fx-border-color: red";
public static boolean tradeAmountOutOfRange(Coin tradeAmount, Offer offer) { public static boolean tradeAmountOutOfRange(Coin tradeAmount, Offer offer) {

View file

@ -21,9 +21,9 @@ import javafx.scene.paint.*;
public class Colors { public class Colors {
public static final Paint BLUE = Color.valueOf("#0f87c3"); public static final Paint BLUE = Color.valueOf("#0f87c3");
public static final Paint LIGHT_GREY = Color.valueOf("#AAAAAA"); public static final Paint LIGHT_GREY = Color.valueOf("#CCCCCC");
public static final Paint MID_GREY = Color.valueOf("#666666"); public static final Paint MID_GREY = Color.valueOf("#666666");
public static final Paint DARK_GREY = Color.valueOf("#333333"); public static final Paint DARK_GREY = Color.valueOf("#333333");
public static final Paint GREEN = Color.valueOf("#00AA00"); public static final Paint GREEN = Color.valueOf("#009900");
} }

View file

@ -87,7 +87,7 @@ public class Transitions {
darken.setBrightness(0.0); darken.setBrightness(0.0);
blur.setInput(darken); blur.setInput(darken);
KeyValue kv2 = new KeyValue(darken.brightnessProperty(), -0.3); KeyValue kv2 = new KeyValue(darken.brightnessProperty(), -0.1);
KeyFrame kf2 = new KeyFrame(Duration.millis(duration), kv2); KeyFrame kf2 = new KeyFrame(Duration.millis(duration), kv2);
timeline.getKeyFrames().addAll(kf1, kf2); timeline.getKeyFrames().addAll(kf1, kf2);
} }

View file

@ -20,8 +20,8 @@ package io.bitsquare.trade;
import io.bitsquare.btc.BlockChainFacade; import io.bitsquare.btc.BlockChainFacade;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletFacade;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoFacade;
import io.bitsquare.gui.components.Popups;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.listeners.TakeOfferRequestListener;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
import io.bitsquare.settings.Settings; import io.bitsquare.settings.Settings;
import io.bitsquare.trade.handlers.ErrorMessageHandler; import io.bitsquare.trade.handlers.ErrorMessageHandler;
@ -48,9 +48,7 @@ import com.google.bitcoin.utils.Fiat;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
@ -80,8 +78,6 @@ public class TradeManager {
private final WalletFacade walletFacade; private final WalletFacade walletFacade;
private final CryptoFacade cryptoFacade; private final CryptoFacade cryptoFacade;
private final List<TakeOfferRequestListener> takeOfferRequestListeners = new ArrayList<>();
//TODO store TakerAsSellerProtocol in trade //TODO store TakerAsSellerProtocol in trade
private final Map<String, SellerTakesOfferProtocol> takerAsSellerProtocolMap = new HashMap<>(); private final Map<String, SellerTakesOfferProtocol> takerAsSellerProtocolMap = new HashMap<>();
private final Map<String, BuyerAcceptsOfferProtocol> offererAsBuyerProtocolMap = new HashMap<>(); private final Map<String, BuyerAcceptsOfferProtocol> offererAsBuyerProtocolMap = new HashMap<>();
@ -132,19 +128,6 @@ public class TradeManager {
} }
///////////////////////////////////////////////////////////////////////////////////////////
// Event Listeners
///////////////////////////////////////////////////////////////////////////////////////////
public void addTakeOfferRequestListener(TakeOfferRequestListener listener) {
takeOfferRequestListeners.add(listener);
}
public void removeTakeOfferRequestListener(TakeOfferRequestListener listener) {
takeOfferRequestListeners.remove(listener);
}
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Manage offers // Manage offers
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -404,10 +387,17 @@ public class TradeManager {
// If the user has shut down the app we lose the offererAsBuyerProtocolMap // If the user has shut down the app we lose the offererAsBuyerProtocolMap
// Also we don't support yet offline messaging (mail box) // Also we don't support yet offline messaging (mail box)
public void bankTransferInited(String tradeId) { public void bankTransferInited(String tradeId) {
if (offererAsBuyerProtocolMap.get(tradeId) != null) {
offererAsBuyerProtocolMap.get(tradeId).onUIEventBankTransferInited(); offererAsBuyerProtocolMap.get(tradeId).onUIEventBankTransferInited();
trades.get(tradeId).setState(Trade.State.PAYMENT_STARTED); trades.get(tradeId).setState(Trade.State.PAYMENT_STARTED);
persistTrades(); persistTrades();
} }
else {
// For usability tests we don't want to crash
Popups.openWarningPopup("Sorry, you cannot continue. You have restarted the application in the meantime. " +
"Interruption of the trade process is not supported yet. Will need more time to be implemented.");
}
}
public void onFiatReceived(String tradeId) { public void onFiatReceived(String tradeId) {
takerAsSellerProtocolMap.get(tradeId).onUIEventFiatReceived(); takerAsSellerProtocolMap.get(tradeId).onUIEventFiatReceived();
@ -428,7 +418,6 @@ public class TradeManager {
if (tradeMessage instanceof RequestTakeOfferMessage) { if (tradeMessage instanceof RequestTakeOfferMessage) {
createOffererAsBuyerProtocol(tradeId, sender); createOffererAsBuyerProtocol(tradeId, sender);
takeOfferRequestListeners.stream().forEach(e -> e.onTakeOfferRequested(tradeId, sender));
} }
else if (tradeMessage instanceof RespondToTakeOfferRequestMessage) { else if (tradeMessage instanceof RespondToTakeOfferRequestMessage) {
takerAsSellerProtocolMap.get(tradeId).onRespondToTakeOfferRequestMessage( takerAsSellerProtocolMap.get(tradeId).onRespondToTakeOfferRequestMessage(

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 895 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 557 B

After

Width:  |  Height:  |  Size: 2.5 KiB

Before After
Before After