2024-09-10 13:32:31 +00:00
|
|
|
|
import QtQuick 2.15
|
|
|
|
|
import QtQuick.Layouts 1.15
|
2024-08-06 16:04:22 +00:00
|
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
import StatusQ.Components.private 0.1
|
|
|
|
|
|
|
|
|
|
import AppLayouts.Wallet.controls 1.0
|
|
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
// required properties
|
2024-08-13 12:03:35 +00:00
|
|
|
|
required property var assetsModel
|
2024-08-06 16:04:22 +00:00
|
|
|
|
required property var selectedProvider
|
|
|
|
|
required property string selectedTokenKey
|
|
|
|
|
required property int selectedNetworkChainId
|
|
|
|
|
required property var filteredFlatNetworksModel
|
|
|
|
|
|
|
|
|
|
signal networkSelected(int chainId)
|
|
|
|
|
signal tokenSelected(string tokensKey)
|
|
|
|
|
|
2024-09-10 13:32:31 +00:00
|
|
|
|
onSelectedTokenKeyChanged: assetSelector.update()
|
|
|
|
|
onSelectedNetworkChainIdChanged: assetSelector.update()
|
2024-08-13 12:03:35 +00:00
|
|
|
|
|
2024-08-06 16:04:22 +00:00
|
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
|
|
StatusListItem {
|
2024-08-13 12:03:35 +00:00
|
|
|
|
objectName: "selectParamsForBuyCryptoPanelHeader"
|
2024-08-06 16:04:22 +00:00
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
|
leftPadding: 0
|
|
|
|
|
rightPadding: 0
|
|
|
|
|
|
|
|
|
|
title: qsTr("Buy via %1").arg(!!root.selectedProvider ? root.selectedProvider.name: "")
|
|
|
|
|
subTitle: qsTr("Select which network and asset")
|
|
|
|
|
statusListItemTitle.color: Theme.palette.directColor1
|
|
|
|
|
asset.name: !!root.selectedProvider ? root.selectedProvider.logoUrl: ""
|
|
|
|
|
asset.isImage: true
|
|
|
|
|
color: Theme.palette.transparent
|
|
|
|
|
enabled: false
|
|
|
|
|
}
|
2024-09-10 13:32:31 +00:00
|
|
|
|
|
2024-08-06 16:04:22 +00:00
|
|
|
|
StatusMenuSeparator {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
}
|
2024-09-10 13:32:31 +00:00
|
|
|
|
|
2024-08-06 16:04:22 +00:00
|
|
|
|
ColumnLayout {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
spacing: 8
|
2024-09-10 13:32:31 +00:00
|
|
|
|
|
2024-08-06 16:04:22 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
text: qsTr("Select network")
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
lineHeight: 22
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
}
|
|
|
|
|
NetworkFilter {
|
|
|
|
|
objectName: "networkFilter"
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
control.popup.width: parent.width
|
|
|
|
|
multiSelection: false
|
|
|
|
|
showSelectionIndicator: false
|
|
|
|
|
flatNetworks: root.filteredFlatNetworksModel
|
|
|
|
|
selection: [root.selectedNetworkChainId]
|
|
|
|
|
onSelectionChanged: root.networkSelected(selection[0])
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-10 13:32:31 +00:00
|
|
|
|
|
2024-08-06 16:04:22 +00:00
|
|
|
|
ColumnLayout {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
spacing: 8
|
2024-09-10 13:32:31 +00:00
|
|
|
|
|
2024-08-06 16:04:22 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
text: qsTr("Select asset")
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
lineHeight: 22
|
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
}
|
2024-09-10 13:32:31 +00:00
|
|
|
|
|
|
|
|
|
AssetSelectorCompact {
|
|
|
|
|
id: assetSelector
|
|
|
|
|
|
|
|
|
|
objectName: "assetSelector"
|
|
|
|
|
|
2024-08-06 16:04:22 +00:00
|
|
|
|
Layout.fillWidth: true
|
2024-09-10 13:32:31 +00:00
|
|
|
|
|
2024-08-13 12:03:35 +00:00
|
|
|
|
model: root.assetsModel
|
2024-08-06 16:04:22 +00:00
|
|
|
|
|
2024-09-10 13:32:31 +00:00
|
|
|
|
onSelected: root.tokenSelected(key)
|
2024-08-06 16:04:22 +00:00
|
|
|
|
|
2024-09-10 13:32:31 +00:00
|
|
|
|
function update() {
|
|
|
|
|
Qt.callLater(()=> {
|
|
|
|
|
if (!root.assetsModel || !root.selectedTokenKey
|
|
|
|
|
|| root.selectedNetworkChainId === -1)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
const entry = ModelUtils.getByKey(root.assetsModel,
|
|
|
|
|
"tokensKey", root.selectedTokenKey)
|
|
|
|
|
if (entry) {
|
2024-09-23 08:15:01 +00:00
|
|
|
|
assetSelector.setSelection(entry.name, entry.symbol,
|
|
|
|
|
entry.iconSource, entry.tokensKey)
|
2024-09-10 13:32:31 +00:00
|
|
|
|
root.tokenSelected(entry.tokensKey)
|
|
|
|
|
} else {
|
|
|
|
|
assetSelector.reset()
|
|
|
|
|
root.tokenSelected("")
|
|
|
|
|
}
|
|
|
|
|
})
|
2024-08-06 16:04:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|