fix(@desktop/wallet): Send Modal Improvements & missing features

fixes #12243
This commit is contained in:
Khushboo Mehta 2023-09-25 14:39:54 +02:00 committed by Khushboo-dev-cpp
parent 89a559745b
commit 29629a3d6d
9 changed files with 36 additions and 44 deletions

View File

@ -166,30 +166,36 @@ QtObject:
proc updateFromNetworks*(self: NetworkModel, path: SuggestedRouteItem, hasGas: bool) =
for i in 0 ..< self.items.len:
let index = self.createIndex(i, 0, nil)
defer: index.delete
self.items[i].amountIn = ""
self.items[i].resetToNetworks
self.items[i].hasGas = true
self.items[i].locked = false
if path.getfromNetwork() == self.items[i].getChainId():
let index = self.createIndex(i, 0, nil)
defer: index.delete
self.items[i].amountIn = path.getAmountIn()
self.items[i].toNetworks = path.getToNetwork()
self.items[i].hasGas = hasGas
self.items[i].locked = path.getAmountInLocked()
self.dataChanged(index, index, @[ModelRole.AmountIn.int, ModelRole.ToNetworks.int, ModelRole.HasGas.int, ModelRole.Locked.int])
self.dataChanged(index, index, @[ModelRole.AmountIn.int, ModelRole.ToNetworks.int, ModelRole.HasGas.int, ModelRole.Locked.int])
proc updateToNetworks*(self: NetworkModel, path: SuggestedRouteItem) =
for i in 0 ..< self.items.len:
let index = self.createIndex(i, 0, nil)
defer: index.delete
self.items[i].amountOut = ""
if path.getToNetwork() == self.items[i].getChainId():
let index = self.createIndex(i, 0, nil)
defer: index.delete
if self.items[i].getAmountOut().len != 0:
self.items[i].amountOut = $(parseInt(self.items[i].getAmountOut()) + parseInt(path.getAmountOut()))
else:
self.items[i].amountOut = path.getAmountOut()
self.dataChanged(index, index, @[ModelRole.AmountOut.int])
self.dataChanged(index, index, @[ModelRole.AmountOut.int])
proc resetPathData*(self: NetworkModel) =
for i in 0 ..< self.items.len:
let index = self.createIndex(i, 0, nil)
defer: index.delete
self.items[i].amountIn = ""
self.items[i].resetToNetworks()
self.items[i].hasGas = true
self.items[i].locked = false
self.items[i].amountOut = ""
self.dataChanged(index, index, @[ModelRole.AmountIn.int, ModelRole.ToNetworks.int, ModelRole.HasGas.int, ModelRole.Locked.int, ModelRole.AmountOut.int])
proc getRouteDisabledNetworkChainIds*(self: NetworkModel): seq[int] =
var disbaledChains: seq[int] = @[]

View File

@ -252,6 +252,8 @@ QtObject:
return self.selectedSenderAccount.address()
proc updatedNetworksWithRoutes*(self: View, paths: seq[SuggestedRouteItem], totalFeesInEth: float) =
self.fromNetworksModel.resetPathData()
self.toNetworksModel.resetPathData()
for path in paths:
let fromChainId = path.getfromNetwork()
let hasGas = self.selectedSenderAccount.getAssets().hasGas(fromChainId, self.fromNetworksModel.getNetworkNativeGasSymbol(fromChainId), totalFeesInEth)

View File

@ -59,7 +59,7 @@ SplitView {
}
}
function splitAndFormatAddressPrefix(textAddrss, isBridgeTx) {
function splitAndFormatAddressPrefix(textAddrss, updateInStore) {
return textAddrss
}

View File

@ -226,11 +226,7 @@ Rectangle {
acceptedButtons: Qt.LeftButton
hoverEnabled: true
enabled: root.clickable && root.state !== "unavailable"
onClicked: {
if(!advancedMode)
disabled = !disabled
root.clicked()
}
onClicked: root.clicked()
}
ColumnLayout {

View File

@ -129,8 +129,6 @@ StatusDialog {
}
width: 556
topMargin: 64 + header.height
bottomPadding: footer.visible ? footer.height : 32
padding: 0
background: StatusDialogBackground {
@ -187,7 +185,6 @@ StatusDialog {
}
}
ColumnLayout {
id: group1
@ -344,7 +341,6 @@ StatusDialog {
implicitHeight: scrollView.implicitHeight
clipTopMargin: 40
clipBottomMargin: popup.bottomPadding
StatusScrollView {
id: scrollView
@ -479,6 +475,7 @@ StatusDialog {
}
footer: SendModalFooter {
width: parent.width
nextButtonText: d.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
maxFiatFees: popup.isLoading ? "..." : popup.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, popup.currencyStore.currentCurrency)
totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate

View File

@ -10,7 +10,7 @@ import utils 1.0
import shared.panels 1.0
Column {
ColumnLayout {
id: root
property int errorType: Constants.NoError
@ -25,29 +25,29 @@ Column {
spacing: 5
StatusIcon {
anchors.horizontalCenter: parent.horizontalCenter
height: 20
width: 20
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: 20
Layout.preferredWidth: 20
icon: "cancel"
color: Theme.palette.dangerColor1
visible: !d.isValid && !isLoading
}
StyledText {
id: txtValidationError
anchors.horizontalCenter: parent.horizontalCenter
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: 18
text: errorType === Constants.SendAmountExceedsBalance ?
qsTr("Balance exceeded") : qsTr("No route found")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 13
height: 18
color: Style.current.danger
visible: !isLoading
}
Loader {
id: loadingComponent
height: 32
width: root.width - Style.current.xlPadding
Layout.preferredHeight: 32
Layout.preferredWidth: root.width - Style.current.xlPadding
active: isLoading && d.isValid
sourceComponent: LoadingComponent { radius: 4 }
}

View File

@ -24,7 +24,7 @@ Rectangle {
radius: 13
color: Theme.palette.indirectColor1
height: text.height + gasSelector.height + gasValidator.height + Style.current.xlPadding
height: columnLayout.height + feesIcon.height
RowLayout {
id: feesLayout
@ -41,6 +41,7 @@ Rectangle {
asset.color: Theme.palette.directColor1
}
Column {
id: columnLayout
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.preferredWidth: root.width - feesIcon.width - Style.current.xlPadding
spacing: isLoading ? 4 : 0

View File

@ -116,16 +116,13 @@ Item {
clickable: root.interactive
onClicked: {
store.toggleFromDisabledChains(model.chainId)
// only recalculate if the a best route was disabled
if(!!model.toNetworks || !disabled)
root.reCalculateSuggestedRoute()
root.reCalculateSuggestedRoute()
}
onLockCard: {
let amount = lock ? (advancedInputCurrencyAmount * Math.pow(10, root.selectedAsset.decimals)).toString(16) : ""
store.lockCard(model.chainId, amount, lock)
d.calculateCustomAmounts()
if(!locked || (d.customAmountToSend <= root.amountToSend && advancedInput.valid))
root.reCalculateSuggestedRoute()
root.reCalculateSuggestedRoute()
}
}
}
@ -187,13 +184,7 @@ Item {
loading: root.isLoading
onClicked: {
store.toggleToDisabledChains(model.chainId)
// only recalculate if the a best route was disabled
if(root.weiToEth(model.amountOut) > 0 || !disabled)
root.reCalculateSuggestedRoute()
}
onOpacityChanged: {
if(opacity === 0 && root.weiToEth(model.amountOut) > 0)
root.reCalculateSuggestedRoute()
root.reCalculateSuggestedRoute()
}
}
}

View File

@ -20,8 +20,7 @@ Rectangle {
signal nextButtonClicked()
width: parent.width
height: 82
implicitHeight: 82
radius: 8
color: Theme.palette.baseColor3