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 1 commit
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
180 changes: 132 additions & 48 deletions atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml
Original file line number Diff line number Diff line change
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,40 @@ 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 {}
reduce.onClicked:
{
let price = General.formatDouble(parseFloat(input_price.text) * 0.99)
setPrice(String(price))
}
increase.onClicked:
{
let price = General.formatDouble(parseFloat(input_price.text) * 1.01)
setPrice(String(price))
}
market.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%"
}
}


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 +122,94 @@ 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
reduce.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume * 0.25)
setVolume(String(volume))
}
market.onClicked:
{
let volume = General.formatDouble(API.app.trading_pg.max_volume * 0.5)
setVolume(String(volume))
}
increase.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"
}
}

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: setMinimumAmount(text)
}

OrderFormSubfield
{
id: minvolume_usd_value
anchors.top: input_minvolume.bottom
anchors.left: input_minvolume.left
anchors.topMargin: 7
reduce.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))
}
market.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))
}
increase.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%"
}
}

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 +246,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 +262,8 @@ ColumnLayout
labelWidth: 0
}

DefaultText {
DefaultText
{
Layout.fillWidth: true
height: _useCustomMinTradeAmountCheckbox.height
horizontalAlignment: Text.AlignLeft
Expand All @@ -216,4 +274,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))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.0

import "../../../Components"
import App 1.0
import Dex.Themes 1.0 as Dex

RowLayout
{
id: control
property alias fiat_value: fiat_label.text_value
property alias left_label: _left_label.text
property alias middle_label: _middle_label.text
property alias right_label: _right_label.text
property alias market: _market
property alias increase: _increase
property alias reduce: _reduce
property int pixel_size: 12
property int btn_width: 33
spacing: 2
height: 20
width: parent.width

Item
{
width: btn_width
height: parent.height

// Background when market mode is different
DefaultRectangle
{
anchors.centerIn: parent
width: parent.width
height: parent.height
color: Dex.CurrentTheme.tradeMarketModeSelectorNotSelectedBackgroundColor
}

DefaultText
{
id: _left_label
anchors.centerIn: parent
font.pixelSize: pixel_size
color: Dex.CurrentTheme.foregroundColor2
text: "-1%"
}

DefaultMouseArea
{
id: _reduce
anchors.fill: parent
}
}

Item
{

width: btn_width
height: parent.height

// Background when market mode is different
DefaultRectangle
{
anchors.centerIn: parent
width: parent.width
height: parent.height
color: Dex.CurrentTheme.tradeMarketModeSelectorNotSelectedBackgroundColor
}

DefaultText
{
id: _middle_label
anchors.centerIn: parent
font.pixelSize: pixel_size
color: Dex.CurrentTheme.foregroundColor2
text: "0%"
}

DefaultMouseArea
{
id: _market
anchors.fill: parent
}
}
Item
{

width: btn_width
height: parent.height

// Background when market mode is different
DefaultRectangle
{
anchors.centerIn: parent
width: parent.width
height: parent.height
color: Dex.CurrentTheme.tradeMarketModeSelectorNotSelectedBackgroundColor
}

DefaultText
{
id: _right_label
anchors.centerIn: parent
font.pixelSize: pixel_size
color: Dex.CurrentTheme.foregroundColor2
text: "+1%"
}

DefaultMouseArea
{
id: _increase
anchors.fill: parent
}
}

Item { Layout.fillWidth: true }

DefaultText
{
id: fiat_label
text_value: _fiat_text
font.pixelSize: pixel_size
color: Dex.CurrentTheme.foregroundColor2

CexInfoTrigger {}
}
}