Skip to content

Commit

Permalink
Change tickers selectors style in pro trading view
Browse files Browse the repository at this point in the history
  • Loading branch information
Syl committed Dec 6, 2021
1 parent 0c3ff0b commit 16b2a3b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 46 deletions.
61 changes: 22 additions & 39 deletions atomic_defi_design/Dex/Exchange/Trade/SweetDexComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -93,37 +93,26 @@ ComboBox
anchors.rightMargin: 5

// Search input
DefaultTextField
SearchField
{
id: input_coin_filter
background: Item
{
DefaultRectangle
{
anchors.fill: parent
anchors.rightMargin: 2
}
}
id: tickerSearchField

function reset()
{
text = ""
textField.text = ""
renewIndex()
}

placeholderText: qsTr("Search")

font.pixelSize: 16
Layout.preferredWidth: parent.width - 10
Layout.preferredHeight: 30
Layout.alignment: Qt.AlignHCenter

Layout.fillWidth: true
Layout.leftMargin: 0
Layout.preferredHeight: 60
Layout.rightMargin: 2
Layout.topMargin: Layout.leftMargin
color: Dex.CurrentTheme.backgroundColor

onTextChanged:
textField.font.pixelSize: 16
textField.onTextChanged:
{
ticker_list.setFilterFixedString(text)
ticker_list.setFilterFixedString(textField.text)
renewIndex()
}

Expand All @@ -144,31 +133,25 @@ ComboBox
target: popup
function onOpened()
{
input_coin_filter.reset();
input_coin_filter.forceActiveFocus();
tickerSearchField.reset();
tickerSearchField.forceActiveFocus();
}
function onClosed() { input_coin_filter.reset() }
function onClosed() { tickerSearchField.reset() }
}
}
Item

DefaultListView
{
Layout.maximumHeight: popup.max_height - 100
Layout.fillWidth: true
implicitHeight: popup_list_view.contentHeight + 5
DefaultListView

model: control.popup.visible ? control.delegateModel : null
currentIndex: control.highlightedIndex

DefaultMouseArea
{
id: popup_list_view
// Scrollbar appears if this extra space is not added
model: control.popup.visible ? control.delegateModel : null
currentIndex: control.highlightedIndex
anchors.fill: parent
anchors.rightMargin: 2

DefaultMouseArea
{
anchors.fill: parent
acceptedButtons: Qt.NoButton
}
acceptedButtons: Qt.NoButton
}
}
}
Expand All @@ -178,7 +161,7 @@ ComboBox
width: parent.width
y: -5
height: parent.height + 10
border.width: 1
radius: 10
}
}

Expand Down
11 changes: 4 additions & 7 deletions atomic_defi_design/Dex/Exchange/Trade/TickerSelector.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@ SweetDexComboBox
onCurrentValueChanged:
{
// User input
if(combo.index_changed)
{
if(combo.index_changed) {
combo.index_changed = false
// Set the ticker
if (currentValue !== undefined)
if(currentValue !== undefined)
setPair(left_side, currentValue)
}
// List change
else
{
else {
// Correct the index
if (currentText.indexOf(ticker) === -1)
{
if(currentText.indexOf(ticker) === -1) {
const target_index = indexOfValue(ticker)
if(currentIndex !== target_index)
currentIndex = target_index
Expand Down

0 comments on commit 16b2a3b

Please sign in to comment.