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

Fix orderbook cancel button #2419

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Changes from all 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
126 changes: 66 additions & 60 deletions atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Item
color: Qaterial.Colors.amber
}

// Insufficient funds tooltip
DexLabel
{
id: tooltip_text
Expand Down Expand Up @@ -101,6 +102,7 @@ Item
anchors.fill: parent
hoverEnabled: true

// Populate form with selected order
onClicked:
{
if (is_mine) return
Expand All @@ -119,6 +121,7 @@ Item
}
}

// Highlight row on mouseover
AnimatedRectangle
{
visible: mouse_area.containsMouse
Expand All @@ -128,16 +131,6 @@ Item
opacity: 0.1
}

Rectangle
{
anchors.verticalCenter: parent.verticalCenter
width: 6
height: 6
radius: width / 2
visible: is_mine
color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor
}

// Progress bar
Rectangle
{
Expand All @@ -161,98 +154,111 @@ Item
}
}

Row
// Price, Qty & Total text values
RowLayout
{
id: row
anchors.fill: parent
anchors.horizontalCenter: parent.horizontalCenter
onWidthChanged: progress.width = ((depth * 100) * (width + 40)) / 100
spacing: 0
spacing: 3

// Dot on the left side of the row to indicate own order
Rectangle
{
Layout.leftMargin: 6
Layout.alignment: Qt.AlignVCenter
opacity: is_mine ? 1 : 0
width: 6
height: 6
radius: 3
color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor
}

// Price
Dex.ElidableText
{
anchors.verticalCenter: parent.verticalCenter
width: parent.width * 0.31
Layout.fillHeight: true
Layout.minimumWidth: 90
Layout.alignment: Qt.AlignVCenter
text: { new BigNumber(price).toFixed(8) }
font.family: DexTypo.fontFamily
font.pixelSize: 12
color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
wrapMode: Text.NoWrap
}

Item { width: parent.width * 0.01 }

// Quantity
Dex.ElidableText
{
anchors.verticalCenter: parent.verticalCenter
width: parent.width * 0.37
Layout.fillHeight: true
Layout.minimumWidth: 90
Layout.alignment: Qt.AlignVCenter
text: { new BigNumber(base_max_volume).toFixed(6) }
font.family: DexTypo.fontFamily
font.pixelSize: 12
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
onTextChanged: depth_bar.width = ((depth * 100) * (mouse_area.width + 40)) / 100
wrapMode: Text.NoWrap
}

Item { width: parent.width * 0.01 }

// Total
Dex.ElidableText
{
anchors.verticalCenter: parent.verticalCenter
width: parent.width * 0.30
rightPadding: (is_mine) && (mouse_area.containsMouse || cancel_button.containsMouse) ? 30 : 0
id: total_text
Layout.fillHeight: true
Layout.minimumWidth: 90
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
font.family: DexTypo.fontFamily
font.pixelSize: 12
text: { new BigNumber(total).toFixed(6) }
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
wrapMode: Text.NoWrap

Behavior on rightPadding { NumberAnimation { duration: 150 } }
}
}
}

Qaterial.ColorIcon
{
id: cancel_button_text
property bool requested_cancel: false

visible: is_mine && !requested_cancel

anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 1
anchors.right: parent.right
anchors.rightMargin: mouse_area.containsMouse || cancel_button.containsMouse ? 12 : 6

Behavior on iconSize
{
NumberAnimation
// Cancel button
Item
{
duration: 200
}
}

iconSize: mouse_area.containsMouse || cancel_button.containsMouse? 16 : 0
id: cancel_flat_btn
Layout.fillHeight: true
width: 30
Layout.alignment: Qt.AlignVCenter

color: cancel_button.containsMouse ?
Qaterial.Colors.red : mouse_area.containsMouse ?
DexTheme.foregroundColor: Qaterial.Colors.red
MouseArea
{
id: cancel_mouse_area
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
}

DefaultMouseArea
{
id: cancel_button
anchors.fill: parent
hoverEnabled: true
Qaterial.FlatButton
{
id: cancel_button_orderbook
anchors.centerIn: parent
anchors.fill: parent
opacity: is_mine ? 1 : 0

onClicked:
{
if (!is_mine) return
onClicked: {
if (uuid) cancelOrder(uuid);
}

cancel_button_text.requested_cancel = true
cancelOrder(uuid)
Qaterial.ColorIcon
{
anchors.centerIn: parent
iconSize: 16
color: Dex.CurrentTheme.warningColor
source: Qaterial.Icons.close
visible: is_mine
scale: is_mine && mouse_area.containsMouse ? 1 : 0
Behavior on scale { NumberAnimation { duration: 150 } }
}
}
}
}
}
Expand Down