Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add form shortcuts, min vol input #1944

Merged
merged 6 commits into from Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
191 changes: 143 additions & 48 deletions atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml
Expand Up @@ -65,6 +65,7 @@ ColumnLayout
left_text: qsTr("Price")
right_text: right_ticker
enabled: !(API.app.trading_pg.preffered_order.price !== undefined)
color: enabled ? Dex.CurrentTheme.foregroundColor1 : Dex.CurrentTheme.foregroundColor2
text: backend_price
width: parent.width
height: 41
Expand All @@ -73,27 +74,45 @@ ColumnLayout
onTextChanged: setPrice(text)
}

DefaultText
OrderFormSubfield
{
id: price_usd_value
anchors.right: input_price.right
anchors.top: input_price.bottom
anchors.left: input_price.left
anchors.topMargin: 7

text_value: General.getFiatText(non_null_price, right_ticker)
font.pixelSize: input_price.font.pixelSize
color: Dex.CurrentTheme.foregroundColor2

CexInfoTrigger {}
visible: !API.app.trading_pg.invalid_cex_price
left_btn.onClicked:
{
let price = General.formatDouble(parseFloat(input_price.text) - (General.formatDouble(API.app.trading_pg.cex_price)*0.01))
if (price < 0) price = 0
setPrice(String(price))
}
right_btn.onClicked:
{
let price = General.formatDouble(parseFloat(input_price.text) + (General.formatDouble(API.app.trading_pg.cex_price)*0.01))
setPrice(String(price))
}
middle_btn.onClicked:
{
if (input_price.text == "0") setPrice("1")
let price = General.formatDouble(API.app.trading_pg.cex_price)
setPrice(String(price))
}
fiat_value: General.getFiatText(non_null_price, right_ticker)
left_label: "-1%"
middle_label: "0%"
right_label: "+1%"
left_tooltip_text: "Reduce 1% relative to CEX market price."
middle_tooltip_text: "Use CEX market price."
right_tooltip_text: "Increase 1% relative to CEX market price."
}
}


Item
{
Layout.preferredWidth: parent.width
Layout.topMargin: 10
Layout.preferredHeight: input_volume.height + inputVolumePrice.height + inputVolumePrice.anchors.topMargin
Layout.topMargin: 8
Layout.preferredHeight: input_volume.height + volume_usd_value.height + volume_usd_value.anchors.topMargin

AmountField
{
Expand All @@ -108,26 +127,100 @@ ColumnLayout
onTextChanged: setVolume(text)
}

DefaultText
OrderFormSubfield
{
id: inputVolumePrice
anchors.right: input_volume.right
id: volume_usd_value
anchors.top: input_volume.bottom
anchors.topMargin: price_usd_value.anchors.topMargin
anchors.left: input_volume.left
anchors.topMargin: 7
left_btn.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume * 0.25)
setVolume(String(volume))
}
middle_btn.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume * 0.5)
setVolume(String(volume))
}
right_btn.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume)
setVolume(String(volume))
}
fiat_value: General.getFiatText(non_null_volume, left_ticker)
left_label: "25%"
middle_label: "50%"
right_label: "Max"
left_tooltip_text: "Swap 25% of your balance."
middle_tooltip_text: "Swap 50% of your balance."
right_tooltip_text: "Swap maximum balance."
}
}

text_value: General.getFiatText(non_null_volume, left_ticker)
font.pixelSize: input_volume.font.pixelSize
color: Dex.CurrentTheme.foregroundColor2
Item
{
visible: _useCustomMinTradeAmountCheckbox.checked
Layout.preferredWidth: parent.width
Layout.topMargin: 8
Layout.preferredHeight: input_minvolume.height + volume_usd_value.height + volume_usd_value.anchors.topMargin

CexInfoTrigger {}
AmountField
{
id: input_minvolume
width: parent.width
height: 41
radius: 18
left_text: qsTr("Min Volume")
right_text: left_ticker
placeholderText: sell_mode ? qsTr("Min amount to sell") : qsTr("Min amount to receive")
text: API.app.trading_pg.min_trade_vol
onTextChanged: if (API.app.trading_pg.min_trade_vol != text) setMinimumAmount(text)
}

OrderFormSubfield
{
id: minvolume_usd_value
anchors.top: input_minvolume.bottom
anchors.left: input_minvolume.left
anchors.topMargin: 7
left_btn.onClicked:
{
let volume = API.app.trading_pg.max_volume * 0.05
if (volume > parseFloat(input_volume.text))
volume = parseFloat(input_volume.text)
setMinimumAmount(General.formatDouble(volume))
}
middle_btn.onClicked:
{
let volume = API.app.trading_pg.max_volume * 0.10
if (volume > parseFloat(input_volume.text))
volume = parseFloat(input_volume.text)
setMinimumAmount(General.formatDouble(volume))
}
right_btn.onClicked:
{
let volume = API.app.trading_pg.max_volume * 0.20
if (volume > parseFloat(input_volume.text))
volume = parseFloat(input_volume.text)
setMinimumAmount(General.formatDouble(volume))
}
fiat_value: General.getFiatText(non_null_volume, left_ticker)
left_label: "5%"
middle_label: "10%"
right_label: "20%"
left_tooltip_text: "Minimum accepted trade equals 5% of your balance."
smk762 marked this conversation as resolved.
Show resolved Hide resolved
middle_tooltip_text: "Minimum accepted trade equals 10% of your balance."
right_tooltip_text: "Minimum accepted trade equals 20% of your balance."
}
}

Item
{
Layout.preferredWidth: parent.width
Layout.preferredHeight: minVolLabel.height
Layout.topMargin: 6
Layout.topMargin: 8
visible: !_useCustomMinTradeAmountCheckbox.checked

DefaultText
{
Expand Down Expand Up @@ -164,34 +257,9 @@ ColumnLayout
}
}

DefaultRangeSlider
{
id: _volumeRange

function getRealValue() { return first.position * (first.to - first.from); }
function getRealValue2() { return second.position * (second.to - second.from); }

enabled: input_volume.enabled && !(!sell_mode && General.isZero(non_null_price)) && to > 0

Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: parent.width

from: API.app.trading_pg.orderbook.current_min_taker_vol
to: Math.max(0, parseFloat(max_volume))

first.value: parseFloat(API.app.trading_pg.min_trade_vol)

firstDisabled: !_useCustomMinTradeAmountCheckbox.checked

second.value: parseFloat(non_null_volume)

first.onValueChanged: if (first.pressed) setMinimumAmount(General.formatDouble(first.value))
second.onValueChanged: if (second.pressed) setVolume(General.formatDouble(second.value))
}

RowLayout
{
Layout.topMargin: 15
Layout.topMargin: 10
Layout.rightMargin: 2
Layout.leftMargin: 2
Layout.fillWidth: true
Expand All @@ -205,7 +273,8 @@ ColumnLayout
labelWidth: 0
}

DefaultText {
DefaultText
{
Layout.fillWidth: true
height: _useCustomMinTradeAmountCheckbox.height
horizontalAlignment: Text.AlignLeft
Expand All @@ -216,4 +285,30 @@ ColumnLayout
font.pixelSize: 13
}
}
}

DefaultRangeSlider
{
id: _volumeRange
visible: false

function getRealValue() { return first.position * (first.to - first.from); }
function getRealValue2() { return second.position * (second.to - second.from); }

enabled: input_volume.enabled && !(!sell_mode && General.isZero(non_null_price)) && to > 0

Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: parent.width

from: API.app.trading_pg.orderbook.current_min_taker_vol
to: Math.max(0, parseFloat(max_volume))

first.value: parseFloat(API.app.trading_pg.min_trade_vol)

firstDisabled: !_useCustomMinTradeAmountCheckbox.checked

second.value: parseFloat(non_null_volume)

first.onValueChanged: if (first.pressed) setMinimumAmount(General.formatDouble(first.value))
second.onValueChanged: if (second.pressed) setVolume(General.formatDouble(second.value))
}
}