Skip to content

Commit

Permalink
Merge branch 'dev' into add/order-info
Browse files Browse the repository at this point in the history
  • Loading branch information
smk762 committed Apr 2, 2024
2 parents af650fd + 8dbad10 commit 85e69fd
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 75 deletions.
10 changes: 2 additions & 8 deletions atomic_defi_design/Dex/Exchange/ProView/TradingInfo/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ import "../../../Components"
import "../../Trade"
import "../../ProView"

Widget
ColumnLayout
{
width: 450
Layout.preferredWidth: 450
property alias currentIndex: tabView.currentIndex

title: qsTr("Trading Information")

background: null
margins: 0


Qaterial.LatoTabBar
{
id: tabView
Expand Down
89 changes: 89 additions & 0 deletions atomic_defi_design/Dex/Exchange/Trade/Market.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

import Qaterial 1.0 as Qaterial

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

// OrderBook / Component import
import "OrderBook/" as OrderBook

// Best Order
import "BestOrder/" as BestOrder


ColumnLayout
{
Layout.minimumWidth: 350
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignTop
property alias currentIndex: marketTabView.currentIndex

Qaterial.LatoTabBar
{
id: marketTabView
property int orderbook: 0
property int best_orders: 1

background: null
Layout.leftMargin: 6

Qaterial.LatoTabButton
{
text: qsTr("Orderbook")
font.pixelSize: 14
textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2
textSecondaryColor: Dex.CurrentTheme.foregroundColor2
indicatorColor: Dex.CurrentTheme.foregroundColor
}
Qaterial.LatoTabButton
{
text: qsTr("Best Orders")
font.pixelSize: 14
textColor: checked ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2
textSecondaryColor: Dex.CurrentTheme.foregroundColor2
indicatorColor: Dex.CurrentTheme.foregroundColor
}
}

Rectangle
{
Layout.fillHeight: true
color: Dex.CurrentTheme.floatingBackgroundColor
radius: 10
Layout.preferredWidth: 350

Qaterial.SwipeView
{
id: marketSwipeView
clip: true
interactive: false
currentIndex: marketTabView.currentIndex
anchors.fill: parent

onCurrentIndexChanged:
{
marketSwipeView.currentItem.update();
}

OrderBook.Vertical
{
id: orderBook
Layout.fillHeight: true
Layout.fillWidth: true
}

// Best Orders
BestOrder.List
{
id: bestOrders
Layout.fillHeight: true
Layout.fillWidth: true
}
}
}
}
3 changes: 2 additions & 1 deletion atomic_defi_design/Dex/Exchange/Trade/OrderBook/Vertical.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Dex.Themes 1.0 as Dex
Widget
{
title: qsTr("Order Book")
readonly property string pair_trades_24hr: API.app.trading_pg.pair_trades_24hr
readonly property string pair_volume_24hr: API.app.trading_pg.pair_volume_24hr
readonly property string pair: atomic_qt_utilities.retrieve_main_ticker(left_ticker) + "/" + atomic_qt_utilities.retrieve_main_ticker(right_ticker)

Expand Down Expand Up @@ -61,7 +62,7 @@ Widget
Layout.bottomMargin: 2
Layout.alignment: Qt.AlignHCenter
color: Dex.CurrentTheme.foregroundColor2
text_value: pair + qsTr(" traded 24hrs: %1").arg("<b>" + General.convertUsd(pair_volume_24hr) + "</b>")
text_value: pair + qsTr(" 24hrs | %1 | %2 trades").arg(General.convertUsd(pair_volume_24hr)).arg(pair_trades_24hr)
font.pixelSize: Style.textSizeSmall1
}
}
45 changes: 6 additions & 39 deletions atomic_defi_design/Dex/Exchange/Trade/ProView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ RowLayout

property alias tickerSelectors: selectors
property alias trInfo: tradingInfo
property alias orderBook: orderBook
property alias bestOrders: bestOrders
property alias marketsOrderBook: marketsOrderBook
property alias placeOrderForm: placeOrderForm

function selectOrder(
Expand Down Expand Up @@ -112,20 +111,15 @@ RowLayout
ColumnLayout
{
Layout.alignment: Qt.AlignTop

Layout.minimumWidth: selectors.visible || tradingInfo.visible ? 450 : -1
Layout.maximumWidth: (!orderBook.visible && !bestOrders.visible) || (!placeOrderForm.visible) ? -1 : 450
Layout.fillWidth: true

Layout.fillHeight: true

spacing: 10

// Ticker selectors.
TickerSelectors
{
id: selectors

Layout.fillWidth: true
Layout.preferredHeight: 70
}
Expand All @@ -134,47 +128,20 @@ RowLayout
TradingInfo.Main
{
id: tradingInfo

Layout.fillWidth: true
Layout.maximumWidth: 450
Layout.fillHeight: true

resizable: false
}
}

WidgetContainer
// Best Orders & Order Book
Market
{
property real _orderBookHeightRatio: 0.65
property real _bestOrdersHeightRatio: 0.35

Layout.minimumWidth: orderBook.visible || bestOrders.visible ? 350 : -1
id: marketsOrderBook
Layout.maximumWidth: 350
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignTop
spacing: 4

onHeightChanged:
{
orderBook.height = getHeight(_orderBookHeightRatio);
bestOrders.height = getHeight(_bestOrdersHeightRatio);
}

OrderBook.Vertical
{
id: orderBook

width: parent.width
minHeight: 320
}

// Best Orders
BestOrder.List
{
id: bestOrders

width: parent.width
minHeight: 140
}
}

// Place order form.
Expand Down
3 changes: 1 addition & 2 deletions atomic_defi_design/Dex/Exchange/Trade/Trade.qml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ Item

proViewTickerSelectors: proView.tickerSelectors
proViewTrInfo: proView.trInfo
proViewOrderBook: proView.orderBook
proViewBestOrders: proView.bestOrders
proViewMarketsOrderBook: proView.marketsOrderBook
proViewPlaceOrderForm: proView.placeOrderForm
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ Item
// property var proViewChart
property var proViewTickerSelectors
property var proViewTrInfo
property var proViewOrderBook
property var proViewBestOrders
property var proViewMarketsOrderBook
property var proViewPlaceOrderForm

Item
Expand Down Expand Up @@ -131,11 +130,7 @@ Item

HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 }

CheckEye { text: qsTr("Order Book"); target: proViewOrderBook }

HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 }

CheckEye { text: qsTr("Best Orders"); target: proViewBestOrders }
CheckEye { text: qsTr("Markets"); target: proViewMarketsOrderBook }

HorizontalLine { width: parent.width - 20; anchors.horizontalCenter: parent.horizontalCenter; opacity: .4 }

Expand Down
10 changes: 10 additions & 0 deletions src/core/atomicdex/pages/qt.trading.page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ namespace atomic_dex
this->m_preferred_order = std::nullopt;
this->m_fees = QVariantMap();
this->m_cex_price = "0";
this->m_pair_trades_24hr = "0";
this->m_pair_volume_24hr = "0";
this->m_post_clear_forms = true;
this->set_selected_order_status(SelectedOrderStatus::None);
Expand Down Expand Up @@ -1394,15 +1395,24 @@ namespace atomic_dex
const auto* market_selector = get_market_pairs_mdl();
const auto& base = utils::retrieve_main_ticker(market_selector->get_left_selected_coin().toStdString(), true);
const auto& rel = utils::retrieve_main_ticker(market_selector->get_right_selected_coin().toStdString(), true);
QString trades = QString::fromStdString(defi_stats_service.get_trades_24h(base, rel));
QString vol = QString::fromStdString(defi_stats_service.get_volume_24h_usd(base, rel));

if (vol != m_pair_volume_24hr)
{
m_pair_trades_24hr = trades;
emit pairTrades24hrChanged();
m_pair_volume_24hr = vol;
emit pairVolume24hrChanged();
}
}

QString
trading_page::get_pair_trades_24hr() const
{
return m_pair_trades_24hr;
}

QString
trading_page::get_pair_volume_24hr() const
{
Expand Down
4 changes: 4 additions & 0 deletions src/core/atomicdex/pages/qt.trading.page.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace atomic_dex
Q_PROPERTY(SelectedOrderStatus selected_order_status READ get_selected_order_status WRITE set_selected_order_status NOTIFY selectedOrderStatusChanged)
Q_PROPERTY(QString price_reversed READ get_price_reversed NOTIFY priceReversedChanged)
Q_PROPERTY(QString pair_volume_24hr READ get_pair_volume_24hr NOTIFY pairVolume24hrChanged)
Q_PROPERTY(QString pair_trades_24hr READ get_pair_trades_24hr NOTIFY pairTrades24hrChanged)
Q_PROPERTY(QString cex_price READ get_cex_price NOTIFY cexPriceChanged)
Q_PROPERTY(QString cex_price_reversed READ get_cex_price_reversed NOTIFY cexPriceReversedChanged)
Q_PROPERTY(QString cex_price_diff READ get_cex_price_diff NOTIFY cexPriceDiffChanged)
Expand Down Expand Up @@ -115,6 +116,7 @@ namespace atomic_dex
QString m_total_amount{"0.00777"};
QString m_cex_price{"0"};
QString m_pair_volume_24hr{"0"};
QString m_pair_trades_24hr{"0"};
QString m_minimal_trading_amount{"0.0001"};
std::optional<nlohmann::json> m_preferred_order;
boost::synchronized_value<QVariantMap> m_fees;
Expand Down Expand Up @@ -197,6 +199,7 @@ namespace atomic_dex
void set_total_amount(QString total_amount);
[[nodiscard]] QString get_base_amount() const;
[[nodiscard]] QString get_rel_amount() const;
[[nodiscard]] QString get_pair_trades_24hr() const;
[[nodiscard]] QString get_pair_volume_24hr() const;
[[nodiscard]] QString get_cex_price() const;
[[nodiscard]] QString get_cex_price_reversed() const;
Expand Down Expand Up @@ -238,6 +241,7 @@ namespace atomic_dex
void baseAmountChanged();
void relAmountChanged();
void feesChanged();
void pairTrades24hrChanged();
void pairVolume24hrChanged();
void cexPriceChanged();
void cexPriceReversedChanged();
Expand Down
Loading

0 comments on commit 85e69fd

Please sign in to comment.