2022-11-23 17:58:22 +00:00
|
|
|
import QtQuick 2.13
|
2023-02-02 15:28:39 +00:00
|
|
|
import QtQuick.Layouts 1.14
|
2022-11-23 17:58:22 +00:00
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-12-16 08:50:56 +00:00
|
|
|
import StatusQ.Components 0.1
|
2022-11-23 17:58:22 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
|
2023-02-02 15:28:39 +00:00
|
|
|
Item {
|
2022-11-23 17:58:22 +00:00
|
|
|
id: root
|
|
|
|
|
2023-04-06 12:59:24 +00:00
|
|
|
property var assets: null
|
2022-11-23 17:58:22 +00:00
|
|
|
signal tokenSelected(var selectedToken)
|
2023-04-18 16:05:24 +00:00
|
|
|
signal tokenHovered(var selectedToken, bool hovered)
|
2022-11-23 17:58:22 +00:00
|
|
|
property var searchTokenSymbolByAddressFn: function (address) {
|
|
|
|
return ""
|
|
|
|
}
|
2022-12-16 08:50:56 +00:00
|
|
|
property var getNetworkIcon: function(chainId){}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
property string searchString
|
|
|
|
readonly property var updateSearchText: Backpressure.debounce(root, 1000, function(inputText) {
|
|
|
|
d.searchString = inputText
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-02-02 15:28:39 +00:00
|
|
|
implicitWidth: contentLayout.implicitWidth
|
|
|
|
implicitHeight: contentLayout.implicitHeight
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: contentLayout
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2023-04-18 16:05:24 +00:00
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: label
|
|
|
|
elide: Text.ElideRight
|
|
|
|
text: qsTr("Token to send")
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
2023-02-02 15:28:39 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
2023-04-18 16:05:24 +00:00
|
|
|
Layout.preferredHeight: tokenList.height
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
color: Theme.palette.indirectColor1
|
|
|
|
radius: 8
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
StatusListView {
|
|
|
|
id: tokenList
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
width: parent.width
|
2023-04-18 16:05:24 +00:00
|
|
|
height: tokenList.contentHeight
|
|
|
|
|
|
|
|
header: SearchBoxWithRightIcon {
|
2022-11-23 17:58:22 +00:00
|
|
|
width: parent.width
|
|
|
|
placeholderText: qsTr("Search for token or enter token address")
|
|
|
|
onTextChanged: Qt.callLater(d.updateSearchText, text)
|
|
|
|
}
|
2023-02-02 15:28:39 +00:00
|
|
|
|
2023-04-18 16:05:24 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.assets
|
|
|
|
filters: [
|
|
|
|
ExpressionFilter {
|
|
|
|
expression: {
|
|
|
|
var tokenSymbolByAddress = searchTokenSymbolByAddressFn(d.searchString)
|
|
|
|
tokenList.positionViewAtBeginning()
|
|
|
|
return visibleForNetwork && (
|
|
|
|
symbol.startsWith(d.searchString.toUpperCase()) || name.toUpperCase().startsWith(d.searchString.toUpperCase()) || (tokenSymbolByAddress!=="" && symbol.startsWith(tokenSymbolByAddress))
|
|
|
|
)
|
|
|
|
}
|
2023-02-02 15:28:39 +00:00
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
delegate: TokenBalancePerChainDelegate {
|
|
|
|
width: ListView.view.width
|
|
|
|
getNetworkIcon: root.getNetworkIcon
|
|
|
|
onTokenSelected: root.tokenSelected(selectedToken)
|
|
|
|
onTokenHovered: root.tokenHovered(selectedToken, hovered)
|
|
|
|
}
|
2023-02-02 15:28:39 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
}
|
|
|
|
}
|