import QtQuick 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 StatusQ.Core.Utils 0.1 as StatusQUtils Item { id: root property var store property var bestRoutes property var selectedAccount property var selectedAsset property var allNetworks property bool customMode: false property double amountToSend: 0 property double requiredGasInEth: 0 property bool errorMode: { if(customMode) { return (d.customAmountToSend > amountToSend) || (d.customAmountToSend < amountToSend) || (d.customAmountToReceive > amountToSend) || (d.customAmountToReceive < amountToSend) } else { return !d.thereIsApossibleRoute } } property bool interactive: true property bool showPreferredChains: false property var weiToEth: function(wei) {} property var reCalculateSuggestedRoute: function() {} QtObject { id: d property double customAmountToSend: 0 property double customAmountToReceive: 0 property bool thereIsApossibleRoute: false function resetAllSetValues() { for(var i = 0; i 0) root.reCalculateSuggestedRoute() } } // To-do needed for custom view // onAdvancedInputTextChanged: { // if(selectedNetwork && selectedNetwork.chainName === model.chainName) // d.customAmountToReceive = isNaN(parseFloat(advancedInputText)) ? 0 : parseFloat(advancedInputText) // } } } } } Canvas { id: canvas x: networkCardsLayout.x + fromNetworksLayout.x y: networkCardsLayout.y width: networkCardsLayout.width height: networkCardsLayout.height function clear() { if(available) { var ctx = getContext("2d"); if(ctx) ctx.reset() } } onPaint: { d.resetAllSetValues() d.thereIsApossibleRoute = false if(bestRoutes === undefined) return // in case you are drwaing multiple routes we need an offset so that the lines dont overlap let yOffsetFrom = 0 let yOffsetTo = 0 let xOffset = 0 // Get the canvas context var ctx = getContext("2d"); for(var i = 0; i< bestRoutes.length; i++) { var fromN, toN = null for(var j = 0; j