2023-02-17 14:09:15 +00:00
|
|
|
|
import QtQuick 2.13
|
2022-07-01 11:24:32 +00:00
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-07-03 08:51:15 +00:00
|
|
|
|
import StatusQ 0.1
|
2022-07-01 11:24:32 +00:00
|
|
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
2022-10-17 10:17:25 +00:00
|
|
|
|
id: root
|
2022-07-01 11:24:32 +00:00
|
|
|
|
|
2022-11-23 17:58:22 +00:00
|
|
|
|
property var store
|
2023-02-17 14:09:15 +00:00
|
|
|
|
property int minReceiveCryptoDecimals: 0
|
2022-10-17 10:17:25 +00:00
|
|
|
|
property bool isLoading: false
|
2022-11-23 17:58:22 +00:00
|
|
|
|
property bool isBridgeTx: false
|
2024-03-05 09:27:40 +00:00
|
|
|
|
property bool isCollectiblesTransfer: false
|
2024-07-03 08:51:15 +00:00
|
|
|
|
property var fromNetworksList
|
2024-07-16 14:36:44 +00:00
|
|
|
|
property var suggestedToNetworksList
|
2022-10-17 10:17:25 +00:00
|
|
|
|
property var weiToEth: function(wei) {}
|
2023-02-17 12:56:31 +00:00
|
|
|
|
property var formatCurrencyAmount: function () {}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
property var reCalculateSuggestedRoute: function() {}
|
2022-11-25 09:13:02 +00:00
|
|
|
|
property bool errorMode: false
|
2022-12-19 13:02:56 +00:00
|
|
|
|
property int errorType: Constants.NoError
|
2024-02-05 16:44:49 +00:00
|
|
|
|
property string selectedSymbol
|
2024-07-16 14:36:44 +00:00
|
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
|
|
StatusRoundIcon {
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
radius: 8
|
2022-08-11 11:55:08 +00:00
|
|
|
|
asset.name: "flash"
|
2022-12-14 21:06:14 +00:00
|
|
|
|
asset.color: Theme.palette.directColor1
|
2022-07-01 11:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2022-10-17 10:17:25 +00:00
|
|
|
|
Layout.preferredWidth: root.width
|
2023-01-27 13:16:42 +00:00
|
|
|
|
spacing: 4
|
2022-07-01 11:24:32 +00:00
|
|
|
|
StatusBaseText {
|
2024-02-12 16:44:35 +00:00
|
|
|
|
Layout.maximumWidth: parent.width
|
2022-07-01 11:24:32 +00:00
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
font.weight: Font.Medium
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
text: qsTr("Networks")
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
}
|
|
|
|
|
StatusBaseText {
|
2024-02-12 16:44:35 +00:00
|
|
|
|
Layout.maximumWidth: parent.width
|
2022-07-01 11:24:32 +00:00
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.baseColor1
|
2024-07-17 11:54:38 +00:00
|
|
|
|
text: isBridgeTx ? qsTr("Routes will be automatically calculated to give you the lowest cost.") :
|
2024-07-08 20:14:30 +00:00
|
|
|
|
qsTr("The networks where the recipient will receive tokens. Amounts calculated automatically for the lowest cost.")
|
2022-07-01 11:24:32 +00:00
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
}
|
2024-07-16 14:36:44 +00:00
|
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
|
ScrollView {
|
|
|
|
|
Layout.fillWidth: true
|
2023-01-27 13:16:42 +00:00
|
|
|
|
Layout.preferredHeight: visible ? row.height + 10 : 0
|
|
|
|
|
Layout.topMargin: Style.current.smallPadding
|
2022-07-01 11:24:32 +00:00
|
|
|
|
contentWidth: row.width
|
|
|
|
|
contentHeight: row.height + 10
|
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
|
|
|
|
|
clip: true
|
2023-01-27 13:16:42 +00:00
|
|
|
|
visible: root.isBridgeTx ? true : !root.isLoading ? root.errorType === Constants.NoError : false
|
2022-12-14 21:06:14 +00:00
|
|
|
|
Column {
|
2022-07-01 11:24:32 +00:00
|
|
|
|
id: row
|
|
|
|
|
spacing: Style.current.padding
|
2024-07-16 14:36:44 +00:00
|
|
|
|
|
|
|
|
|
// TODO: This transformation should come from an adaptor outside this component
|
|
|
|
|
LeftJoinModel {
|
|
|
|
|
id: toNetworksListLeftJoinModel
|
|
|
|
|
|
|
|
|
|
leftModel: root.suggestedToNetworksList
|
|
|
|
|
rightModel: root.store.flatNetworksModel
|
|
|
|
|
joinRole: "chainId"
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-01 11:24:32 +00:00
|
|
|
|
Repeater {
|
|
|
|
|
id: repeater
|
2022-07-21 12:15:02 +00:00
|
|
|
|
objectName: "networksList"
|
2024-07-16 14:36:44 +00:00
|
|
|
|
model: isBridgeTx ? root.fromNetworksList : toNetworksListLeftJoinModel
|
2022-11-23 17:58:22 +00:00
|
|
|
|
delegate: isBridgeTx ? networkItem : routeItem
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BalanceExceeded {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2023-01-27 13:16:42 +00:00
|
|
|
|
Layout.topMargin: Style.current.smallPadding
|
2022-12-19 13:02:56 +00:00
|
|
|
|
errorType: root.errorType
|
2023-01-27 13:16:42 +00:00
|
|
|
|
isLoading: root.isLoading && !root.isBridgeTx
|
2022-11-23 17:58:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ButtonGroup {
|
|
|
|
|
buttons: repeater.children
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: routeItem
|
|
|
|
|
StatusListItem {
|
2023-08-15 18:21:51 +00:00
|
|
|
|
objectName: model.chainName
|
2022-11-23 17:58:22 +00:00
|
|
|
|
leftPadding: 5
|
|
|
|
|
rightPadding: 5
|
2022-12-14 21:06:14 +00:00
|
|
|
|
implicitWidth: 410
|
2023-08-15 18:21:51 +00:00
|
|
|
|
title: model.chainName
|
2022-11-25 09:13:02 +00:00
|
|
|
|
subTitle: {
|
2024-03-05 09:27:40 +00:00
|
|
|
|
if(root.isCollectiblesTransfer)
|
2023-08-31 10:27:15 +00:00
|
|
|
|
return ""
|
2023-08-15 18:21:51 +00:00
|
|
|
|
let amountOut = root.weiToEth(model.amountOut)
|
2024-02-05 16:44:49 +00:00
|
|
|
|
return root.formatCurrencyAmount(amountOut, root.selectedSymbol, {"minDecimals": root.minReceiveCryptoDecimals})
|
2022-11-25 09:13:02 +00:00
|
|
|
|
}
|
|
|
|
|
statusListItemSubTitle.color: root.errorMode ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
|
2022-11-23 17:58:22 +00:00
|
|
|
|
asset.width: 32
|
|
|
|
|
asset.height: 32
|
2023-08-15 18:21:51 +00:00
|
|
|
|
asset.name: Style.svg("tiny/" + model.iconUrl)
|
2022-11-23 17:58:22 +00:00
|
|
|
|
asset.isImage: true
|
|
|
|
|
color: "transparent"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: networkItem
|
|
|
|
|
StatusRadioButton {
|
|
|
|
|
id: gasRectangle
|
|
|
|
|
width: contentItem.implicitWidth
|
|
|
|
|
contentItem: StatusListItem {
|
|
|
|
|
id: card
|
|
|
|
|
objectName: chainName
|
2024-07-17 11:54:38 +00:00
|
|
|
|
leftPadding: 16
|
|
|
|
|
rightPadding: 6
|
2023-01-27 13:16:42 +00:00
|
|
|
|
implicitWidth: 410
|
2022-11-23 17:58:22 +00:00
|
|
|
|
title: chainName
|
2024-02-05 16:44:49 +00:00
|
|
|
|
subTitle: root.formatCurrencyAmount(tokenBalance.amount, root.selectedSymbol)
|
2022-11-23 17:58:22 +00:00
|
|
|
|
statusListItemSubTitle.color: Theme.palette.primaryColor1
|
|
|
|
|
asset.width: 32
|
|
|
|
|
asset.height: 32
|
|
|
|
|
asset.name: Style.svg("tiny/" + iconUrl)
|
|
|
|
|
asset.isImage: true
|
2024-07-17 11:54:38 +00:00
|
|
|
|
border.color: gasRectangle.checked ? Theme.palette.primaryColor1 : Theme.palette.primaryColor2
|
2022-11-23 17:58:22 +00:00
|
|
|
|
color: {
|
2024-07-17 11:54:38 +00:00
|
|
|
|
if (sensor.containsMouse) {
|
|
|
|
|
return Theme.palette.baseColor2
|
2022-07-01 11:24:32 +00:00
|
|
|
|
}
|
2024-07-17 11:54:38 +00:00
|
|
|
|
Theme.palette.statusListItem.backgroundColor
|
|
|
|
|
}
|
|
|
|
|
onClicked: {
|
|
|
|
|
if(!gasRectangle.checked)
|
|
|
|
|
gasRectangle.toggle()
|
2022-07-01 11:24:32 +00:00
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
}
|
|
|
|
|
onCheckedChanged: {
|
2023-08-31 10:27:15 +00:00
|
|
|
|
store.setRouteDisabledChains(chainId, !gasRectangle.checked)
|
2022-11-23 17:58:22 +00:00
|
|
|
|
if(checked)
|
|
|
|
|
root.reCalculateSuggestedRoute()
|
|
|
|
|
}
|
|
|
|
|
checked: index === 0
|
|
|
|
|
indicator: Item {
|
|
|
|
|
width: card.width
|
|
|
|
|
height: card.height
|
|
|
|
|
}
|
|
|
|
|
Component.onCompleted: {
|
2023-08-31 10:27:15 +00:00
|
|
|
|
store.setRouteDisabledChains(chainId, !gasRectangle.checked)
|
2022-11-23 17:58:22 +00:00
|
|
|
|
if(index === (repeater.count -1))
|
|
|
|
|
root.reCalculateSuggestedRoute()
|
2022-07-01 11:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|