1717
1818package bisq .desktop .main .content .mu_sig .offer .components .amount_selection ;
1919
20- import bisq .bisq_easy .BisqEasyTradeAmountLimits ;
2120import bisq .common .market .Market ;
2221import bisq .common .market .MarketRepository ;
2322import bisq .common .monetary .Monetary ;
23+ import bisq .common .monetary .MonetaryRange ;
2424import bisq .desktop .common .view .Model ;
2525import bisq .offer .Direction ;
2626import javafx .beans .property .BooleanProperty ;
2727import javafx .beans .property .DoubleProperty ;
28- import javafx .beans .property .IntegerProperty ;
2928import javafx .beans .property .ObjectProperty ;
3029import javafx .beans .property .SimpleBooleanProperty ;
3130import javafx .beans .property .SimpleDoubleProperty ;
32- import javafx .beans .property .SimpleIntegerProperty ;
3331import javafx .beans .property .SimpleObjectProperty ;
3432import javafx .beans .property .SimpleStringProperty ;
3533import javafx .beans .property .StringProperty ;
3634import lombok .Getter ;
3735import lombok .Setter ;
3836
37+ import java .util .Map ;
38+
3939@ Getter
4040public class MuSigAmountSelectionModel implements Model {
41- private final double sliderMin = 0 ;
42- private final double sliderMax = 1 ;
43- public final int amountBoxWidth = 300 ;
44- public final int amountBoxHeight = 120 ;
41+ static final String SLIDER_TRACK_DEFAULT_COLOR = "-bisq-dark-grey-50" ;
42+ static final String SLIDER_TRACK_MARKER_COLOR = "-bisq2-green" ;
43+ static final int RANGE_INPUT_TEXT_MAX_LENGTH = 11 ;
44+ static final int FIXED_INPUT_TEXT_MAX_LENGTH = 18 ;
4545
46- private final ObjectProperty <Monetary > maxOrFixedBaseSideAmount = new SimpleObjectProperty <>();
47- private final ObjectProperty <Monetary > maxOrFixedQuoteSideAmount = new SimpleObjectProperty <>();
46+ private final Map <Integer , Integer > widthByNumCharsMap ;
47+ @ Setter
48+ private Market market = MarketRepository .getDefaultBtcFiatMarket ();
49+ @ Setter
50+ private Direction direction = Direction .BUY ;
51+
52+ // Range
53+ private final BooleanProperty useRangeAmount = new SimpleBooleanProperty ();
54+
55+ private final ObjectProperty <MonetaryRange > quoteSideTradeAmountLimits = new SimpleObjectProperty <>();
56+
57+ private final ObjectProperty <MonetaryRange > rangeBaseSideAmount = new SimpleObjectProperty <>();
58+ private final ObjectProperty <MonetaryRange > rangeQuoteSideAmount = new SimpleObjectProperty <>();
59+
60+ private final ObjectProperty <Monetary > maxAllowedQuoteSideAmount = new SimpleObjectProperty <>();
61+ private final ObjectProperty <Monetary > maxAllowedBaseSideAmount = new SimpleObjectProperty <>();
62+
63+ private final StringProperty formattedMinRangeAmount = new SimpleStringProperty ();
64+ private final StringProperty rangeAmountCode = new SimpleStringProperty ();
65+ private final StringProperty formattedMaxAllowedQuoteSideAmount = new SimpleStringProperty ();
66+
67+
68+ // Amounts
4869 private final ObjectProperty <Monetary > minBaseSideAmount = new SimpleObjectProperty <>();
4970 private final ObjectProperty <Monetary > minQuoteSideAmount = new SimpleObjectProperty <>();
50- private final StringProperty spendOrReceiveString = new SimpleStringProperty ();
71+ private final ObjectProperty <Monetary > maxOrFixedBaseSideAmount = new SimpleObjectProperty <>();
72+ private final ObjectProperty <Monetary > maxOrFixedQuoteSideAmount = new SimpleObjectProperty <>();
73+
5174
75+ // Slider
5276 private final DoubleProperty maxOrFixedAmountSliderValue = new SimpleDoubleProperty ();
5377 private final DoubleProperty minAmountSliderValue = new SimpleDoubleProperty ();
5478 private final BooleanProperty maxOrFixedAmountSliderFocus = new SimpleBooleanProperty ();
5579 private final BooleanProperty minAmountSliderFocus = new SimpleBooleanProperty ();
5680 private final BooleanProperty rangeSliderLowThumbFocus = new SimpleBooleanProperty ();
5781 private final BooleanProperty rangeSliderHighThumbFocus = new SimpleBooleanProperty ();
58- private final BooleanProperty isRangeAmountEnabled = new SimpleBooleanProperty ();
5982
60- @ Setter
61- private ObjectProperty <Monetary > minRangeMonetary = new SimpleObjectProperty <>(BisqEasyTradeAmountLimits .DEFAULT_MIN_BTC_TRADE_AMOUNT );
62- @ Setter
63- private ObjectProperty <Monetary > maxRangeMonetary = new SimpleObjectProperty <>(BisqEasyTradeAmountLimits .DEFAULT_MAX_BTC_TRADE_AMOUNT );
64- @ Setter
65- private ObjectProperty <Monetary > minRangeBaseSideValue = new SimpleObjectProperty <>();
66- @ Setter
67- private ObjectProperty <Monetary > maxRangeBaseSideValue = new SimpleObjectProperty <>();
68- @ Setter
69- private ObjectProperty <Monetary > minRangeQuoteSideValue = new SimpleObjectProperty <>();
70- @ Setter
71- private ObjectProperty <Monetary > maxRangeQuoteSideValue = new SimpleObjectProperty <>();
72- private final ObjectProperty <Monetary > maxQuoteAllowedLimitation = new SimpleObjectProperty <>();
73- private final ObjectProperty <Monetary > maxBaseAllowedLimitation = new SimpleObjectProperty <>();
7483 @ Setter
7584 private Monetary leftMarkerQuoteSideValue ;
7685 @ Setter
7786 private Monetary rightMarkerQuoteSideValue ;
7887 private final StringProperty sliderTrackStyle = new SimpleStringProperty ();
79- @ Setter
80- private Market market = MarketRepository .getDefaultBtcFiatMarket ();
81- @ Setter
82- private Direction direction = Direction .BUY ;
83- private final StringProperty description = new SimpleStringProperty ();
84- private final StringProperty minRangeValueAsString = new SimpleStringProperty ();
85- private final StringProperty minRangeCodeAsString = new SimpleStringProperty ();
86- private final StringProperty maxRangeValueLimitationAsString = new SimpleStringProperty ();
87- private final StringProperty maxRangeCodeAsString = new SimpleStringProperty ();
88- private final BooleanProperty showRangeAmountSelection = new SimpleBooleanProperty (false );
89- private final BooleanProperty allowInvertingBaseAndQuoteCurrencies = new SimpleBooleanProperty (false );
90- private final IntegerProperty baseAmountSelectionHBoxWidth = new SimpleIntegerProperty (amountBoxWidth );
88+
89+
90+ // Input type
9191 private final BooleanProperty isDefaultAmountInputBtc = new SimpleBooleanProperty (false );
92- private final BooleanProperty shouldShowMinAmounts = new SimpleBooleanProperty (false );
9392 private final BooleanProperty shouldShowInvertedMinAmounts = new SimpleBooleanProperty (false );
94- private final BooleanProperty shouldShowMaxOrFixedAmounts = new SimpleBooleanProperty (false );
9593 private final BooleanProperty shouldShowInvertedMaxOrFixedAmounts = new SimpleBooleanProperty (false );
94+ private final BooleanProperty shouldShowMaxOrFixedAmounts = new SimpleBooleanProperty (false );
95+ private final BooleanProperty shouldShowMinAmounts = new SimpleBooleanProperty (false );
96+ private final BooleanProperty showRangeAmountSelection = new SimpleBooleanProperty (false );
97+
98+ // Strings
99+ private final StringProperty spendOrReceiveString = new SimpleStringProperty ();
100+ private final StringProperty description = new SimpleStringProperty ();
101+
102+ // Layout
103+ private final double sliderMin = 0 ;
104+ private final double sliderMax = 1 ;
105+ public final int amountBoxWidth = 300 ;
106+ public final int amountBoxHeight = 120 ;
96107 private final BooleanProperty shouldFocusInputTextField = new SimpleBooleanProperty (false );
97108 private final BooleanProperty shouldApplyNewInputTextFontStyle = new SimpleBooleanProperty (false );
98109
110+ public MuSigAmountSelectionModel (Map <Integer , Integer > widthByNumCharsMap ) {
111+ this .widthByNumCharsMap = widthByNumCharsMap ;
112+ }
113+
99114 void reset () {
100115 maxOrFixedBaseSideAmount .set (null );
101116 maxOrFixedQuoteSideAmount .set (null );
@@ -108,28 +123,22 @@ void reset() {
108123 minAmountSliderFocus .set (false );
109124 rangeSliderLowThumbFocus .set (false );
110125 rangeSliderHighThumbFocus .set (false );
111- isRangeAmountEnabled .set (false );
112- minRangeMonetary .set (BisqEasyTradeAmountLimits .DEFAULT_MIN_BTC_TRADE_AMOUNT );
113- maxRangeMonetary .set (BisqEasyTradeAmountLimits .DEFAULT_MAX_BTC_TRADE_AMOUNT );
114- minRangeBaseSideValue .set (null );
115- maxRangeBaseSideValue .set (null );
116- minRangeQuoteSideValue .set (null );
117- maxRangeQuoteSideValue .set (null );
118- maxQuoteAllowedLimitation .set (null );
119- maxBaseAllowedLimitation .set (null );
126+ useRangeAmount .set (false );
127+ quoteSideTradeAmountLimits .set (null );
128+ rangeBaseSideAmount .set (null );
129+ rangeQuoteSideAmount .set (null );
130+ maxAllowedQuoteSideAmount .set (null );
131+ maxAllowedBaseSideAmount .set (null );
120132 leftMarkerQuoteSideValue = null ;
121133 rightMarkerQuoteSideValue = null ;
122134 sliderTrackStyle .set (null );
123135 market = MarketRepository .getDefaultBtcFiatMarket ();
124136 direction = Direction .BUY ;
125137 description .set (null );
126- minRangeValueAsString .set (null );
127- minRangeCodeAsString .set (null );
128- maxRangeValueLimitationAsString .set (null );
129- maxRangeCodeAsString .set (null );
138+ formattedMinRangeAmount .set (null );
139+ rangeAmountCode .set (null );
140+ formattedMaxAllowedQuoteSideAmount .set (null );
130141 showRangeAmountSelection .set (false );
131- allowInvertingBaseAndQuoteCurrencies .set (false );
132- baseAmountSelectionHBoxWidth .set (amountBoxWidth );
133142 isDefaultAmountInputBtc .set (false );
134143 shouldShowMinAmounts .set (false );
135144 shouldShowInvertedMinAmounts .set (false );
0 commit comments