-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3057 from axpoems/simplify-trade-wizard-2
Consolidate amount and price in create offer wizard
- Loading branch information
Showing
32 changed files
with
2,271 additions
and
1,142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
694 changes: 0 additions & 694 deletions
694
...desktop/src/main/java/bisq/desktop/main/content/bisq_easy/components/AmountComponent.java
This file was deleted.
Oops, something went wrong.
81 changes: 0 additions & 81 deletions
81
.../desktop/src/main/java/bisq/desktop/main/content/bisq_easy/components/BigAmountInput.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...p/desktop/src/main/java/bisq/desktop/main/content/bisq_easy/components/PriceInputBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* 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.main.content.bisq_easy.components; | ||
|
||
import bisq.desktop.components.controls.MaterialTextField; | ||
import javafx.beans.property.StringProperty; | ||
import javafx.beans.value.ChangeListener; | ||
import javafx.geometry.Insets; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.HBox; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class PriceInputBox extends MaterialTextField { | ||
public final static int AMOUNT_BOX_WIDTH = 340; | ||
public final static int AMOUNT_BOX_HEIGHT = 127; | ||
private final static String INPUT_TEXT_9_STYLE_CLASS = "input-text-9"; | ||
private final static String INPUT_TEXT_10_STYLE_CLASS = "input-text-10"; | ||
private final static String INPUT_TEXT_11_STYLE_CLASS = "input-text-11"; | ||
private final static String INPUT_TEXT_12_STYLE_CLASS = "input-text-12"; | ||
private final static String INPUT_TEXT_13_STYLE_CLASS = "input-text-13"; | ||
private final static String INPUT_TEXT_14_STYLE_CLASS = "input-text-14"; | ||
|
||
private final Label textInputSymbolLabel, conversionPriceLabel, conversionPriceLabelSymbol; | ||
private final HBox textInputAndSymbolHBox; | ||
private final ChangeListener<Number> textInputLengthListener; | ||
|
||
public PriceInputBox(String description, String prompt) { | ||
super(description, prompt); | ||
|
||
bg.getStyleClass().setAll("bisq-dual-amount-bg"); | ||
|
||
descriptionLabel.setLayoutX(20); | ||
descriptionLabel.setPadding(new Insets(2, 0, 0, 0)); | ||
textInputSymbolLabel = new Label(); | ||
textInputSymbolLabel.getStyleClass().add("text-input-symbol"); | ||
textInputAndSymbolHBox = new HBox(10, textInputControl, textInputSymbolLabel); | ||
textInputAndSymbolHBox.setLayoutY(27); | ||
|
||
conversionPriceLabel = new Label(); | ||
conversionPriceLabel.getStyleClass().add("conversion-price"); | ||
conversionPriceLabelSymbol = new Label(); | ||
conversionPriceLabelSymbol.getStyleClass().add("conversion-price-symbol"); | ||
HBox conversionPriceBox = new HBox(7, conversionPriceLabel, conversionPriceLabelSymbol); | ||
conversionPriceBox.getStyleClass().add("conversion-price-box"); | ||
conversionPriceBox.setLayoutY(97); | ||
|
||
getChildren().setAll(bg, conversionPriceBox, line, selectionLine, descriptionLabel, textInputAndSymbolHBox, iconButton, helpLabel, errorLabel); | ||
getStyleClass().add("price-input-box"); | ||
|
||
textInputLengthListener = (observable, oldValue, newValue) -> applyFontStyle(newValue.intValue()); | ||
initialize(); | ||
} | ||
|
||
public PriceInputBox(String description) { | ||
this(description, null); | ||
} | ||
|
||
public void initialize() { | ||
textInputControl.lengthProperty().addListener(textInputLengthListener); | ||
} | ||
|
||
public void dispose() { | ||
textInputControl.lengthProperty().removeListener(textInputLengthListener); | ||
} | ||
|
||
public final StringProperty textInputSymbolTextProperty() { | ||
return textInputSymbolLabel.textProperty(); | ||
} | ||
|
||
public final StringProperty conversionPriceTextProperty() { | ||
return conversionPriceLabel.textProperty(); | ||
} | ||
|
||
public final StringProperty conversionPriceSymbolTextProperty() { | ||
return conversionPriceLabelSymbol.textProperty(); | ||
} | ||
|
||
private void applyFontStyle(int length) { | ||
textInputAndSymbolHBox.getStyleClass().clear(); | ||
textInputAndSymbolHBox.getStyleClass().addAll("text-input-and-units-box", | ||
getFontStyleBasedOnTextLength(length)); | ||
} | ||
|
||
@Override | ||
protected double getBgHeight() { | ||
return AMOUNT_BOX_HEIGHT; | ||
} | ||
|
||
private static String getFontStyleBasedOnTextLength(int charCount) { | ||
if (charCount < 9) { | ||
return INPUT_TEXT_9_STYLE_CLASS; | ||
} | ||
if (charCount == 9) { | ||
return INPUT_TEXT_10_STYLE_CLASS; | ||
} | ||
if (charCount == 10) { | ||
return INPUT_TEXT_11_STYLE_CLASS; | ||
} | ||
if (charCount == 11) { | ||
return INPUT_TEXT_12_STYLE_CLASS; | ||
} | ||
if (charCount == 12) { | ||
return INPUT_TEXT_13_STYLE_CLASS; | ||
} | ||
return INPUT_TEXT_14_STYLE_CLASS; | ||
} | ||
} |
Oops, something went wrong.