2024-08-30 15:31:53 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
|
|
|
|
|
|
|
import AppLayouts.Wallet.views 1.0
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
/**
|
|
|
|
Panel holding search field and lists of assets.
|
|
|
|
*/
|
|
|
|
Control {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
/**
|
|
|
|
Expected model structure:
|
|
|
|
|
|
|
|
tokensKey [string] - unique asset's identifier
|
|
|
|
name [string] - asset's name
|
|
|
|
symbol [string] - asset's symbol
|
|
|
|
iconSource [url] - asset's icon
|
|
|
|
currencyBalanceAsString [string] - formatted balance
|
|
|
|
balances [model] - submodel of balances per chain
|
|
|
|
balanceAsString [string] - formatted balance per chain
|
|
|
|
iconUrl [url] - chain's icon
|
|
|
|
**/
|
2024-09-11 11:42:17 +00:00
|
|
|
property var model
|
|
|
|
property string highlightedKey
|
|
|
|
property string nonInteractiveKey
|
|
|
|
|
2024-09-10 12:38:13 +00:00
|
|
|
property string sectionProperty
|
2024-08-30 15:31:53 +00:00
|
|
|
|
|
|
|
signal selected(string key)
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: sfpm
|
|
|
|
|
2024-09-11 11:42:17 +00:00
|
|
|
// workaround for https://github.com/status-im/status-desktop/issues/16310
|
|
|
|
Component.onCompleted: {
|
|
|
|
sourceModel = Qt.binding(() => root.model)
|
|
|
|
}
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
filters: AnyOf {
|
|
|
|
SearchFilter {
|
|
|
|
roleName: "name"
|
|
|
|
searchPhrase: searchBox.text
|
|
|
|
}
|
|
|
|
SearchFilter {
|
|
|
|
roleName: "symbol"
|
|
|
|
searchPhrase: searchBox.text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
TokenSearchBox {
|
|
|
|
id: searchBox
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
placeholderText: qsTr("Search assets")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusDialogDivider {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: listView.count
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusListView {
|
|
|
|
id: listView
|
|
|
|
|
2024-09-11 11:42:17 +00:00
|
|
|
objectName: "assetsListView"
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
clip: true
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.preferredHeight: contentHeight
|
|
|
|
|
|
|
|
model: sfpm
|
2024-09-10 12:38:13 +00:00
|
|
|
section.property: root.sectionProperty
|
|
|
|
|
|
|
|
section.delegate: TokenSelectorSectionDelegate {
|
|
|
|
width: ListView.view.width
|
|
|
|
text: section
|
|
|
|
}
|
|
|
|
|
2024-08-30 15:31:53 +00:00
|
|
|
delegate: TokenSelectorAssetDelegate {
|
|
|
|
required property var model
|
|
|
|
required property int index
|
|
|
|
|
|
|
|
highlighted: tokensKey === root.highlightedKey
|
2024-09-11 11:42:17 +00:00
|
|
|
interactive: tokensKey !== root.nonInteractiveKey
|
2024-08-30 15:31:53 +00:00
|
|
|
|
|
|
|
tokensKey: model.tokensKey
|
|
|
|
name: model.name
|
|
|
|
symbol: model.symbol
|
2024-09-11 11:42:17 +00:00
|
|
|
currencyBalanceAsString: model.currencyBalanceAsString ?? ""
|
2024-08-30 15:31:53 +00:00
|
|
|
iconSource: model.iconSource
|
|
|
|
balancesModel: model.balances
|
|
|
|
|
|
|
|
onClicked: root.selected(model.tokensKey)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|