2020-09-03 20:14:44 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-18 10:55:07 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
2021-10-27 10:25:42 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2021-10-18 10:55:07 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.views 1.0
|
|
|
|
import shared.panels 1.0
|
2021-10-18 10:55:07 +00:00
|
|
|
|
|
|
|
StatusModal {
|
2021-10-22 20:49:47 +00:00
|
|
|
property var store
|
2022-01-04 12:06:05 +00:00
|
|
|
property var contactsStore
|
|
|
|
|
2023-02-07 14:21:32 +00:00
|
|
|
property string commandTitle: qsTr("Send")
|
|
|
|
property string finalButtonLabel: qsTr("Request address")
|
2020-09-03 20:14:44 +00:00
|
|
|
property var sendChatCommand: function () {}
|
2020-09-08 21:22:47 +00:00
|
|
|
property bool isRequested: false
|
2020-09-03 20:14:44 +00:00
|
|
|
|
|
|
|
id: root
|
2021-10-18 10:55:07 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
header.title: root.commandTitle
|
2020-09-03 20:14:44 +00:00
|
|
|
height: 504
|
|
|
|
|
2020-10-28 07:44:09 +00:00
|
|
|
property alias selectRecipient: selectRecipient
|
2020-09-03 20:14:44 +00:00
|
|
|
|
2021-10-18 10:55:07 +00:00
|
|
|
contentItem: Item {
|
|
|
|
width: root.width
|
|
|
|
height: childrenRect.height
|
|
|
|
TransactionStackView {
|
|
|
|
id: stack
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 16
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
|
|
|
|
onGroupActivated: {
|
|
|
|
root.header.title = group.headerText
|
|
|
|
btnNext.text = group.footerText
|
|
|
|
}
|
|
|
|
TransactionFormGroup {
|
|
|
|
id: group1
|
|
|
|
headerText: root.commandTitle
|
2022-04-04 11:26:30 +00:00
|
|
|
footerText: qsTr("Continue")
|
2021-10-18 10:55:07 +00:00
|
|
|
|
2021-10-27 10:25:42 +00:00
|
|
|
StatusAccountSelector {
|
2021-10-18 10:55:07 +00:00
|
|
|
id: selectFromAccount
|
2021-11-15 12:36:22 +00:00
|
|
|
accounts: root.store.accounts
|
2021-10-18 10:55:07 +00:00
|
|
|
selectedAccount: {
|
2021-11-15 12:36:22 +00:00
|
|
|
const currAcc = root.store.currentAccount
|
2021-10-18 10:55:07 +00:00
|
|
|
if (currAcc.walletType !== Constants.watchWalletType) {
|
|
|
|
return currAcc
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
2021-12-23 20:46:58 +00:00
|
|
|
currency: root.store.currentCurrency
|
2021-10-18 10:55:07 +00:00
|
|
|
width: stack.width
|
|
|
|
label: {
|
2022-02-09 09:43:23 +00:00
|
|
|
return root.isRequested ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Receive on account") :
|
|
|
|
qsTr("From account")
|
2021-04-22 04:03:46 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-18 10:55:07 +00:00
|
|
|
SeparatorWithIcon {
|
|
|
|
id: separator
|
|
|
|
anchors.top: selectFromAccount.bottom
|
|
|
|
anchors.topMargin: 19
|
|
|
|
icon.rotation: root.isRequested ? -90 : 90
|
2020-10-07 02:47:21 +00:00
|
|
|
}
|
2020-10-22 15:29:05 +00:00
|
|
|
|
2021-10-18 10:55:07 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: addressRequiredInfo
|
|
|
|
anchors.right: selectRecipient.right
|
|
|
|
anchors.bottom: selectRecipient.top
|
|
|
|
anchors.bottomMargin: -Style.current.padding
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Address request required")
|
2021-10-18 10:55:07 +00:00
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
visible: addressRequiredValidator.isWarn
|
|
|
|
}
|
2020-10-22 15:29:05 +00:00
|
|
|
|
2021-10-18 10:55:07 +00:00
|
|
|
RecipientSelector {
|
|
|
|
id: selectRecipient
|
2021-12-23 20:46:58 +00:00
|
|
|
accounts: root.store.accounts
|
2022-01-04 12:06:05 +00:00
|
|
|
contactsStore: root.contactsStore
|
2021-10-18 10:55:07 +00:00
|
|
|
label: root.isRequested ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("From") :
|
|
|
|
qsTr("To")
|
2021-10-18 10:55:07 +00:00
|
|
|
anchors.top: separator.bottom
|
|
|
|
anchors.topMargin: 10
|
|
|
|
width: stack.width
|
|
|
|
onSelectedRecipientChanged: {
|
|
|
|
addressRequiredValidator.address = root.isRequested ? selectFromAccount.selectedAccount.address : selectRecipient.selectedRecipient.address
|
|
|
|
}
|
2020-10-22 15:29:05 +00:00
|
|
|
}
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
2021-10-18 10:55:07 +00:00
|
|
|
TransactionFormGroup {
|
|
|
|
id: group2
|
|
|
|
headerText: root.commandTitle
|
2022-04-04 11:26:30 +00:00
|
|
|
footerText: qsTr("Preview")
|
2021-10-18 10:55:07 +00:00
|
|
|
|
|
|
|
AssetAndAmountInput {
|
|
|
|
id: txtAmount
|
|
|
|
selectedAccount: selectFromAccount.selectedAccount
|
2021-11-15 12:36:22 +00:00
|
|
|
currentCurrency: root.store.currentCurrency
|
2022-02-09 00:04:49 +00:00
|
|
|
getFiatValue: root.store.getFiatValue
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// getCryptoValue: root.store.walletModelInst.balanceView.getCryptoValue
|
2021-10-18 10:55:07 +00:00
|
|
|
validateBalance: !root.isRequested
|
|
|
|
width: stack.width
|
|
|
|
}
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
2021-10-18 10:55:07 +00:00
|
|
|
TransactionFormGroup {
|
|
|
|
id: group3
|
|
|
|
headerText: root.isRequested ?
|
2022-04-04 11:26:30 +00:00
|
|
|
qsTr("Preview") :
|
|
|
|
qsTr("Transaction preview")
|
2021-10-18 10:55:07 +00:00
|
|
|
footerText: root.finalButtonLabel
|
2020-09-03 20:14:44 +00:00
|
|
|
|
2021-10-18 10:55:07 +00:00
|
|
|
TransactionPreview {
|
|
|
|
id: pvwTransaction
|
|
|
|
width: stack.width
|
|
|
|
fromAccount: root.isRequested ? selectRecipient.selectedRecipient : selectFromAccount.selectedAccount
|
|
|
|
toAccount: root.isRequested ? selectFromAccount.selectedAccount : selectRecipient.selectedRecipient
|
|
|
|
asset: txtAmount.selectedAsset
|
|
|
|
amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount }
|
|
|
|
toWarn: addressRequiredValidator.isWarn
|
2021-12-23 20:46:58 +00:00
|
|
|
currency: root.store.currentCurrency
|
2021-10-18 10:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AddressRequiredValidator {
|
|
|
|
id: addressRequiredValidator
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
}
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:55:07 +00:00
|
|
|
leftButtons: [
|
2022-08-02 13:48:07 +00:00
|
|
|
StatusBackButton {
|
2020-09-03 20:14:44 +00:00
|
|
|
visible: !stack.isFirstGroup
|
|
|
|
onClicked: {
|
|
|
|
stack.back()
|
|
|
|
}
|
|
|
|
}
|
2021-10-18 10:55:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
rightButtons: [
|
2021-10-27 10:25:42 +00:00
|
|
|
StatusButton {
|
2020-09-03 20:14:44 +00:00
|
|
|
id: btnNext
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Next")
|
2020-09-17 09:08:31 +00:00
|
|
|
enabled: stack.currentGroup.isValid && !stack.currentGroup.isPending
|
2020-09-03 20:14:44 +00:00
|
|
|
onClicked: {
|
2020-09-17 09:08:31 +00:00
|
|
|
const validity = stack.currentGroup.validate()
|
|
|
|
if (validity.isValid && !validity.isPending) {
|
2020-09-03 20:14:44 +00:00
|
|
|
if (stack.isLastGroup) {
|
2021-12-23 20:46:58 +00:00
|
|
|
root.sendChatCommand(selectFromAccount.selectedAccount.address,
|
2020-09-03 20:14:44 +00:00
|
|
|
txtAmount.selectedAmount,
|
2022-05-19 08:53:57 +00:00
|
|
|
txtAmount.selectedAsset.symbol,
|
2020-09-08 21:22:47 +00:00
|
|
|
txtAmount.selectedAsset.decimals)
|
2021-12-23 20:46:58 +00:00
|
|
|
return root.close()
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
|
|
|
stack.next()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-18 10:55:07 +00:00
|
|
|
]
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
|
|
|
|