Skip to content

Commit

Permalink
feat(@desktop/wallet): Implements the Send Modal Footer required for …
Browse files Browse the repository at this point in the history
…simple send

fixes #16918
  • Loading branch information
Khushboo-dev-cpp committed Dec 9, 2024
1 parent 77003fb commit 16e67a2
Show file tree
Hide file tree
Showing 11 changed files with 270 additions and 34 deletions.
56 changes: 56 additions & 0 deletions storybook/pages/SendModalFooterPage.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import QtQuick 2.14
import QtQuick.Controls 2.14

import StatusQ.Core.Theme 0.1

import Storybook 1.0

import AppLayouts.Wallet.views 1.0

SplitView {
orientation: Qt.Vertical
Logs { id: logs }

Rectangle {
SplitView.fillHeight: true
SplitView.fillWidth: true
color: Theme.palette.indirectColor1

SendModalFooter {
id: footer
anchors.centerIn: parent
width: 595

loading: loadingCheckbox.checked

onReviewSendClicked: console.log("review send clicked")
}
}

LogsAndControlsPanel {
id: logsAndControlsPanel

SplitView.minimumHeight: 100
SplitView.preferredHeight: 200

logsView.logText: logs.logText

Column {
CheckBox {
id: loadingCheckbox
text: "loading"
}

Button {
text: "set fees values"
onClicked: {
loadingCheckbox.checked = false
footer.estimateTime = "~60s"
footer.estimatedFees = "1.45 EUR"
}
}
}
}
}

// category: Views
18 changes: 12 additions & 6 deletions storybook/pages/SimpleSendModalPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ SplitView {
})
}
}

property var setFees: Backpressure.debounce(root, 1500, function () {
simpleSend.estimatedTime = "~60s"
simpleSend.estimatedFiatFees = "1.45 EUR"
simpleSend.estimatedCryptoFees = "0.0007 ETH"
})
}

PopupBackground {
Expand Down Expand Up @@ -87,7 +93,6 @@ SplitView {
modal: false
closePolicy: Popup.CloseOnEscape

feesLoading: feesLoadingCheckbox.checked
interactive: interactiveCheckbox.checked

accountsModel: d.walletAccountsModel
Expand Down Expand Up @@ -116,6 +121,12 @@ SplitView {
}
})

onFetchFees: {
console.log("Fetch fees...")
d.setFees()
}
onReviewSendClicked: console.log("Review send clicked")

Binding on selectedAccountAddress {
value: accountsCombobox.currentValue ?? ""
}
Expand Down Expand Up @@ -491,11 +502,6 @@ SplitView {
checked: true
}

CheckBox {
id: feesLoadingCheckbox
text: "Fees loading"
}

Text {
text: "Select an accounts"
}
Expand Down
2 changes: 2 additions & 0 deletions storybook/pages/SimpleTransactionsFeesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ SplitView {
anchors.centerIn: parent
width: 400

cryptoFees: qsTr("0.0007 ETH")
fiatFees: qsTr("1.45 EUR")
loading: loadingCheckbox.checked
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/app/AppLayouts/Wallet/panels/RecipientSelectorPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import StatusQ.Controls 0.1
import StatusQ.Components 0.1

import shared.controls 1.0 as SharedControls
// TODO: remove all files and dependecies with this location once old send modal is removed
// TODO: remove all files and dependencies with this location once old send modal is removed
import shared.popups.send.controls 1.0
import shared.popups.send 1.0

Expand Down
17 changes: 12 additions & 5 deletions ui/app/AppLayouts/Wallet/panels/SimpleTransactionsFees.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ Control {
id: root

/** property to set fees in fiat along with fiat symbol **/
property alias cryptoFees: cryptoFeesText.text
property string cryptoFees
/** property to set fees in crypto along with crypto symbol **/
property alias fiatFees: fiatFeesText.text

property string fiatFees
/** property to set loading state in the fees component **/
property bool loading

QtObject {
id: d

readonly property string loadingText: "----------"
}

implicitHeight: 64

padding: Theme.padding
Expand Down Expand Up @@ -63,7 +68,8 @@ Control {
lineHeightMode: Text.FixedHeight
lineHeight: 22

text: qsTr("0.0007 ETH")
text: !!root.cryptoFees ? root.cryptoFees:
d.loadingText
}
}
StatusTextWithLoadingState {
Expand All @@ -76,7 +82,8 @@ Control {
lineHeightMode: Text.FixedHeight
lineHeight: 22

text: qsTr("1.45 EUR")
text: !!root.fiatFees ? root.fiatFees:
d.loadingText
}
}
}
91 changes: 71 additions & 20 deletions ui/app/AppLayouts/Wallet/popups/simpleSend/SimpleSendModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ StatusDialog {
required property var fnFormatCurrencyAmount

/** input property to decide if send modal is interactive or prefilled **/
property bool interactive
/** input property to decide if fees are loading **/
property bool feesLoading
property bool interactive: true

/** input property to set estimated time **/
property string estimatedTime
/** input property to set estimated fees in fiat **/
property string estimatedFiatFees
/** input property to set estimated fees in crypto **/
property string estimatedCryptoFees

/** property to set and expose currently selected account **/
property string selectedAccountAddress
Expand All @@ -100,11 +105,18 @@ StatusDialog {
/** TODO: replace with new and improved recipient selector StatusDateRangePicker
TBD under https://github.com/status-im/status-desktop/issues/16916 **/
property alias selectedRecipientAddress: recipientsPanel.selectedRecipientAddress
/** Input function to resolve Ens Name **/
required property var fnResolveENS
/** Output function to set resolved ens name values **/
function ensNameResolved(resolvedPubKey, resolvedAddress, uuid) {
recipientsPanel.ensNameResolved(resolvedPubKey, resolvedAddress, uuid)
}

/** Output signal to request signing of the transaction **/
signal reviewSendClicked()
/** Output signal to request fetching fees **/
signal fetchFees()

QtObject {
id: d

Expand Down Expand Up @@ -162,6 +174,10 @@ StatusDialog {
}
})

readonly property var debounceSetSelectedAmount: Backpressure.debounce(root, 1500, function() {
root.selectedAmount = amountToSend.text
})

readonly property bool isCollectibleSelected: {
if(!selectedTokenEntry)
return false
Expand All @@ -180,11 +196,43 @@ StatusDialog {
return WalletUtils.calculateMaxSafeSendAmount(maxCryptoBalance, d.selectedCryptoTokenSymbol)
}

readonly property bool allValuesFilled: !!root.selectedAccountAddress &&
root.selectedChainId !== 0 &&
!!root.selectedTokenKey &&
!!root.selectedRecipientAddress &&
!!root.selectedAmount
function allValuesFilledCorrectly() {
return !!root.selectedAccountAddress &&
root.selectedChainId !== 0 &&
!!root.selectedTokenKey &&
!!root.selectedRecipientAddress &&
!!root.selectedAmount &&
!amountToSend.markAsInvalid &&
amountToSend.valid
}

// handle multiple property changes from single changed signal
property var combinedPropertyChangedHandler: [
root.selectedAccountAddress,
root.selectedChainId,
root.selectedTokenKey,
root.selectedRecipientAddress,
root.selectedAmount,
amountToSend.markAsInvalid,
amountToSend.valid]
onCombinedPropertyChangedHandlerChanged: Qt.callLater(() => d.fetchFees())

function resetFees() {
root.estimatedCryptoFees = ""
root.estimatedFiatFees = ""
root.estimatedTime = ""
}

function fetchFees() {
resetFees()
if(allValuesFilledCorrectly()) {
root.fetchFees()
}
}

readonly property bool feesIsLoading: !root.estimatedCryptoFees &&
!root.estimatedFiatFees &&
!root.estimatedTime
}

width: 556
Expand All @@ -198,9 +246,6 @@ StatusDialog {
}

// Bindings needed for exposing and setting raw values from AmountToSend
Binding on selectedAmount {
value: amountToSend.text
}
onSelectedAmountChanged: {
if(!!selectedAmount && amountToSend.text !== root.selectedAmount) {
amountToSend.setValue(root.selectedAmount)
Expand Down Expand Up @@ -343,6 +388,8 @@ StatusDialog {
visible: !!root.selectedTokenKey && !d.isCollectibleSelected
onVisibleChanged: if(visible) forceActiveFocus()

onTextChanged: d.debounceSetSelectedAmount()

bottomRightComponent: MaxSendButton {
id: maxButton

Expand Down Expand Up @@ -414,20 +461,24 @@ StatusDialog {
SimpleTransactionsFees {
Layout.fillWidth: true

loading: root.feesLoading
cryptoFees: root.estimatedCryptoFees
fiatFees: root.estimatedFiatFees
loading: d.feesIsLoading && d.allValuesFilledCorrectly()
}
visible: d.allValuesFilled
visible: d.allValuesFilledCorrectly()
}
}
}
}

// TODO:: move to new location and rework if needed
footer: TransactionModalFooter {
width: parent.width
pending: false
nextButtonText: qsTr("Review Send")
maxFiatFees: "..."
totalTimeEstimate: "..."
footer: SendModalFooter {
width: root.width

estimateTime: root.estimatedTime
estimatedFees: root.estimatedFiatFees

loading: d.feesIsLoading && d.allValuesFilledCorrectly()

onReviewSendClicked: root.reviewSendClicked()
}
}
Loading

0 comments on commit 16e67a2

Please sign in to comment.