mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Add icon to trade message status field
This commit is contained in:
parent
b6094112f0
commit
0c206d7a1a
5 changed files with 158 additions and 16 deletions
78
src/main/java/bisq/desktop/components/TextFieldWithIcon.java
Normal file
78
src/main/java/bisq/desktop/components/TextFieldWithIcon.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.desktop.components;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
|
||||
import javafx.geometry.Pos;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class TextFieldWithIcon extends AnchorPane {
|
||||
public static final Logger log = LoggerFactory.getLogger(TextFieldWithIcon.class);
|
||||
@Getter
|
||||
private final Label iconLabel;
|
||||
private final TextField textField;
|
||||
private final Label dummyTextField;
|
||||
|
||||
public TextFieldWithIcon() {
|
||||
textField = new TextField();
|
||||
textField.setEditable(false);
|
||||
textField.setMouseTransparent(true);
|
||||
textField.setFocusTraversable(false);
|
||||
setLeftAnchor(textField, 0d);
|
||||
setRightAnchor(textField, 0d);
|
||||
|
||||
dummyTextField = new Label();
|
||||
dummyTextField.setWrapText(true);
|
||||
dummyTextField.setAlignment(Pos.CENTER_LEFT);
|
||||
dummyTextField.setTextAlignment(TextAlignment.LEFT);
|
||||
dummyTextField.setMouseTransparent(true);
|
||||
dummyTextField.setFocusTraversable(false);
|
||||
setLeftAnchor(dummyTextField, 0d);
|
||||
dummyTextField.setVisible(false);
|
||||
|
||||
iconLabel = new Label();
|
||||
iconLabel.setLayoutX(0);
|
||||
iconLabel.setLayoutY(3);
|
||||
|
||||
dummyTextField.widthProperty().addListener((observable, oldValue, newValue) -> {
|
||||
iconLabel.setLayoutX(dummyTextField.widthProperty().get() + 20);
|
||||
});
|
||||
|
||||
getChildren().addAll(textField, dummyTextField, iconLabel);
|
||||
}
|
||||
|
||||
public void setIcon(AwesomeIcon iconLabel) {
|
||||
AwesomeDude.setIcon(this.iconLabel, iconLabel);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
textField.setText(text);
|
||||
dummyTextField.setText(text);
|
||||
}
|
||||
}
|
|
@ -71,6 +71,8 @@ import org.bitcoinj.core.Coin;
|
|||
import net.glxn.qrgen.QRCode;
|
||||
import net.glxn.qrgen.image.ImageType;
|
||||
|
||||
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
|
@ -120,10 +122,6 @@ import org.jetbrains.annotations.NotNull;
|
|||
import static bisq.desktop.util.FormBuilder.*;
|
||||
import static javafx.beans.binding.Bindings.createStringBinding;
|
||||
|
||||
|
||||
|
||||
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
|
||||
|
||||
public abstract class EditableOfferView<M extends EditableOfferViewModel> extends ActivatableViewAndModel<AnchorPane, M> {
|
||||
protected final Navigation navigation;
|
||||
private final Preferences preferences;
|
||||
|
|
|
@ -17,16 +17,25 @@
|
|||
|
||||
package bisq.desktop.main.portfolio.pendingtrades.steps.buyer;
|
||||
|
||||
import bisq.desktop.components.TextFieldWithIcon;
|
||||
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||
import bisq.desktop.main.portfolio.pendingtrades.steps.TradeStepView;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.network.MessageState;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.paint.Paint;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
||||
public class BuyerStep3View extends TradeStepView {
|
||||
private final ChangeListener<MessageState> messageStateChangeListener;
|
||||
private TextFieldWithIcon textFieldWithIconWithIcon;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -37,7 +46,7 @@ public class BuyerStep3View extends TradeStepView {
|
|||
super(model);
|
||||
|
||||
messageStateChangeListener = (observable, oldValue, newValue) -> {
|
||||
infoLabel.setText(getInfoText());
|
||||
updateMessageStateInfo();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -46,6 +55,8 @@ public class BuyerStep3View extends TradeStepView {
|
|||
super.activate();
|
||||
|
||||
model.getMessageStateProperty().addListener(messageStateChangeListener);
|
||||
|
||||
updateMessageStateInfo();
|
||||
}
|
||||
|
||||
public void deactivate() {
|
||||
|
@ -59,6 +70,14 @@ public class BuyerStep3View extends TradeStepView {
|
|||
// Info
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
protected void addInfoBlock() {
|
||||
FormBuilder.addTitledGroupBg(gridPane, ++gridRow, 2, getInfoBlockTitle(), Layout.GROUP_DISTANCE);
|
||||
infoLabel = FormBuilder.addMultilineLabel(gridPane, gridRow, "", Layout.FIRST_ROW_AND_GROUP_DISTANCE);
|
||||
textFieldWithIconWithIcon = FormBuilder.addLabelTextFieldWithIcon(gridPane, ++gridRow,
|
||||
Res.get("portfolio.pending.step3_buyer.wait.msgStateInfo.label"), 0).second;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInfoBlockTitle() {
|
||||
return Res.get("portfolio.pending.step3_buyer.wait.headline");
|
||||
|
@ -66,8 +85,39 @@ public class BuyerStep3View extends TradeStepView {
|
|||
|
||||
@Override
|
||||
protected String getInfoText() {
|
||||
return Res.get("portfolio.pending.step3_buyer.wait.info", model.dataModel.getCurrencyCode());
|
||||
}
|
||||
|
||||
private void updateMessageStateInfo() {
|
||||
MessageState messageState = model.getMessageStateProperty().get();
|
||||
return Res.get("portfolio.pending.step3_buyer.wait.info", model.dataModel.getCurrencyCode(), Res.get("message.state." + messageState.name()));
|
||||
textFieldWithIconWithIcon.setText(Res.get("message.state." + messageState.name()));
|
||||
Label iconLabel = textFieldWithIconWithIcon.getIconLabel();
|
||||
switch (messageState) {
|
||||
case UNDEFINED:
|
||||
textFieldWithIconWithIcon.setIcon(AwesomeIcon.QUESTION);
|
||||
iconLabel.setTextFill(Paint.valueOf("#e9a20a"));
|
||||
break;
|
||||
case SENT:
|
||||
textFieldWithIconWithIcon.setIcon(AwesomeIcon.ARROW_RIGHT);
|
||||
iconLabel.setTextFill(Paint.valueOf("#afe193"));
|
||||
break;
|
||||
case ARRIVED:
|
||||
textFieldWithIconWithIcon.setIcon(AwesomeIcon.OK);
|
||||
iconLabel.setTextFill(Paint.valueOf("#0793ad"));
|
||||
break;
|
||||
case STORED_IN_MAILBOX:
|
||||
textFieldWithIconWithIcon.setIcon(AwesomeIcon.ENVELOPE_ALT);
|
||||
iconLabel.setTextFill(Paint.valueOf("#91B6E9"));
|
||||
break;
|
||||
case ACKNOWLEDGED:
|
||||
textFieldWithIconWithIcon.setIcon(AwesomeIcon.OK_SIGN);
|
||||
iconLabel.setTextFill(Paint.valueOf("#009900"));
|
||||
break;
|
||||
case FAILED:
|
||||
textFieldWithIconWithIcon.setIcon(AwesomeIcon.EXCLAMATION_SIGN);
|
||||
iconLabel.setTextFill(Paint.valueOf("#dd0000"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import bisq.desktop.components.InputTextField;
|
|||
import bisq.desktop.components.PasswordTextField;
|
||||
import bisq.desktop.components.SearchComboBox;
|
||||
import bisq.desktop.components.TextFieldWithCopyIcon;
|
||||
import bisq.desktop.components.TextFieldWithIcon;
|
||||
import bisq.desktop.components.TitledGroupBg;
|
||||
import bisq.desktop.components.TxIdTextField;
|
||||
|
||||
|
@ -44,6 +45,8 @@ import bisq.common.util.Tuple4;
|
|||
|
||||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import de.jensd.fx.glyphs.GlyphIcons;
|
||||
import de.jensd.fx.glyphs.materialdesignicons.utils.MaterialDesignIconFactory;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -74,16 +77,7 @@ import javafx.geometry.VPos;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
import de.jensd.fx.glyphs.GlyphIcons;
|
||||
import de.jensd.fx.glyphs.materialdesignicons.utils.MaterialDesignIconFactory;
|
||||
|
||||
public class FormBuilder {
|
||||
private static final Logger log = LoggerFactory.getLogger(FormBuilder.class);
|
||||
public static final String MATERIAL_DESIGN_ICONS = "'Material Design Icons'";
|
||||
public static final String FONTAWESOME_ICONS = "FontAwesome";
|
||||
|
||||
|
@ -211,6 +205,27 @@ public class FormBuilder {
|
|||
return new Tuple2<>(label, textField);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Label + TextFieldWithIcon
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public static Tuple2<Label, TextFieldWithIcon> addLabelTextFieldWithIcon(GridPane gridPane, int rowIndex, String title, double top) {
|
||||
Label label = addLabel(gridPane, rowIndex, title, top);
|
||||
|
||||
TextFieldWithIcon textFieldWithIcon = new TextFieldWithIcon();
|
||||
textFieldWithIcon.setMouseTransparent(true);
|
||||
textFieldWithIcon.setFocusTraversable(false);
|
||||
GridPane.setRowIndex(textFieldWithIcon, rowIndex);
|
||||
GridPane.setColumnIndex(textFieldWithIcon, 1);
|
||||
GridPane.setMargin(textFieldWithIcon, new Insets(top, 0, 0, 0));
|
||||
gridPane.getChildren().add(textFieldWithIcon);
|
||||
|
||||
return new Tuple2<>(label, textFieldWithIcon);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// HyperlinkWithIcon
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -873,6 +888,7 @@ public class FormBuilder {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Label + InfoTextField
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static Tuple2<Label, InfoTextField> addLabelInfoTextfield(GridPane gridPane, int rowIndex, String labelText,
|
||||
String fieldText) {
|
||||
return addLabelInfoTextfield(gridPane, rowIndex, labelText, fieldText, 0);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class AwesomeFontDemo extends Application {
|
|||
root.getChildren().add(button);
|
||||
}
|
||||
|
||||
primaryStage.setScene(new Scene(root, 900, 850));
|
||||
primaryStage.setScene(new Scene(root, 1200, 950));
|
||||
primaryStage.show();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue