2022-07-01 11:24:32 +00:00
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
2022-10-17 10:17:25 +00:00
|
|
|
|
property var bestRoutes
|
2022-07-01 11:24:32 +00:00
|
|
|
|
property double amountToSend: 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
|
2022-12-09 09:10:05 +00:00
|
|
|
|
property var selectedAsset
|
|
|
|
|
property var selectedAccount
|
2022-12-14 21:06:14 +00:00
|
|
|
|
property var toNetworksList: []
|
2022-10-17 10:17:25 +00:00
|
|
|
|
property var weiToEth: function(wei) {}
|
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
|
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
|
2022-07-01 11:24:32 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.maximumWidth: 410
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
font.weight: Font.Medium
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
text: qsTr("Networks")
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
}
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.maximumWidth: 410
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.baseColor1
|
2022-11-23 17:58:22 +00:00
|
|
|
|
text: isBridgeTx ? qsTr("Choose the network to bridge token to") :
|
|
|
|
|
qsTr("The networks where the receipient will receive tokens. Amounts calculated automatically for the lowest cost.")
|
2022-07-01 11:24:32 +00:00
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
}
|
|
|
|
|
ScrollView {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: row.height + 10
|
|
|
|
|
Layout.topMargin: Style.current.bigPadding
|
|
|
|
|
contentWidth: row.width
|
|
|
|
|
contentHeight: row.height + 10
|
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
|
|
|
|
|
clip: true
|
2022-12-19 13:02:56 +00:00
|
|
|
|
visible: !root.isLoading ? root.isBridgeTx ? true : 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
|
|
|
|
|
Repeater {
|
|
|
|
|
id: repeater
|
2022-07-21 12:15:02 +00:00
|
|
|
|
objectName: "networksList"
|
2022-12-14 21:06:14 +00:00
|
|
|
|
model: isBridgeTx ? store.allNetworks : root.toNetworksList
|
2022-11-23 17:58:22 +00:00
|
|
|
|
delegate: isBridgeTx ? networkItem : routeItem
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BalanceExceeded {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
Layout.topMargin: Style.current.bigPadding
|
|
|
|
|
amountToSend: root.amountToSend
|
|
|
|
|
isLoading: root.isLoading
|
2022-12-19 13:02:56 +00:00
|
|
|
|
errorType: root.errorType
|
2022-11-23 17:58:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ButtonGroup {
|
|
|
|
|
buttons: repeater.children
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: routeItem
|
|
|
|
|
StatusListItem {
|
2022-12-14 21:06:14 +00:00
|
|
|
|
objectName: modelData.chainName
|
2022-11-23 17:58:22 +00:00
|
|
|
|
leftPadding: 5
|
|
|
|
|
rightPadding: 5
|
2022-12-14 21:06:14 +00:00
|
|
|
|
implicitWidth: 410
|
|
|
|
|
title: modelData.chainName
|
2022-11-25 09:13:02 +00:00
|
|
|
|
subTitle: {
|
2022-12-14 21:06:14 +00:00
|
|
|
|
let index = store.lockedInAmounts.findIndex(lockedItem => lockedItem !== undefined && lockedItem.chainID === modelData.chainId)
|
2022-11-25 09:13:02 +00:00
|
|
|
|
if(!root.errorMode || index === -1)
|
2022-12-14 21:06:14 +00:00
|
|
|
|
return root.weiToEth(modelData.amountOut)
|
2022-11-25 09:13:02 +00:00
|
|
|
|
else {
|
|
|
|
|
return root.weiToEth(parseInt(store.lockedInAmounts[index].value, 16))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
statusListItemSubTitle.color: root.errorMode ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
|
2022-11-23 17:58:22 +00:00
|
|
|
|
asset.width: 32
|
|
|
|
|
asset.height: 32
|
2022-12-14 21:06:14 +00:00
|
|
|
|
asset.name: Style.svg("tiny/" + modelData.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
|
|
|
|
|
leftPadding: 5
|
|
|
|
|
rightPadding: 5
|
|
|
|
|
implicitWidth: 150
|
|
|
|
|
title: chainName
|
2022-12-29 16:44:51 +00:00
|
|
|
|
property bool tokenBalanceOnChainValid: selectedAccount && selectedAccount !== undefined && selectedAsset !== undefined
|
|
|
|
|
property var tokenBalanceOnChain: tokenBalanceOnChainValid ? root.store.getTokenBalanceOnChain(selectedAccount, chainId, selectedAsset.symbol) : undefined
|
|
|
|
|
subTitle: tokenBalanceOnChain ? LocaleUtils.currencyAmountToLocaleString(tokenBalanceOnChain, root.store.locale) : "N/A"
|
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
|
|
|
|
|
color: {
|
|
|
|
|
if (sensor.containsMouse || highlighted || gasRectangle.checked) {
|
|
|
|
|
return Theme.palette.baseColor2
|
2022-07-01 11:24:32 +00:00
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
return Theme.palette.statusListItem.backgroundColor
|
2022-07-01 11:24:32 +00:00
|
|
|
|
}
|
2022-11-23 17:58:22 +00:00
|
|
|
|
onClicked: gasRectangle.toggle()
|
|
|
|
|
}
|
|
|
|
|
onCheckedChanged: {
|
|
|
|
|
store.addRemoveDisabledToChain(chainId, !gasRectangle.checked)
|
|
|
|
|
if(checked)
|
|
|
|
|
root.reCalculateSuggestedRoute()
|
|
|
|
|
}
|
|
|
|
|
checked: index === 0
|
|
|
|
|
indicator: Item {
|
|
|
|
|
width: card.width
|
|
|
|
|
height: card.height
|
|
|
|
|
}
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
store.addRemoveDisabledToChain(chainId, !gasRectangle.checked)
|
|
|
|
|
if(index === (repeater.count -1))
|
|
|
|
|
root.reCalculateSuggestedRoute()
|
2022-07-01 11:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|