2020-09-03 20:14:44 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
import "../../../../../imports"
|
|
|
|
import "../../../../../shared"
|
|
|
|
import "../../../../../shared/status"
|
|
|
|
|
|
|
|
ModalPopup {
|
|
|
|
property string commandTitle: "Send"
|
|
|
|
property string finalButtonLabel: "Request address"
|
|
|
|
property var sendChatCommand: function () {}
|
2020-09-08 21:22:47 +00:00
|
|
|
property bool isRequested: false
|
2020-10-28 07:44:09 +00:00
|
|
|
signal reset
|
2020-09-03 20:14:44 +00:00
|
|
|
|
|
|
|
id: root
|
|
|
|
title: root.commandTitle
|
|
|
|
height: 504
|
|
|
|
|
2020-10-28 07:44:09 +00:00
|
|
|
property alias selectRecipient: selectRecipient
|
2020-09-03 20:14:44 +00:00
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
stack.reset()
|
2020-10-28 07:44:09 +00:00
|
|
|
root.reset()
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TransactionStackView {
|
|
|
|
id: stack
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
onGroupActivated: {
|
|
|
|
root.title = group.headerText
|
2020-09-17 09:08:31 +00:00
|
|
|
btnNext.text = group.footerText
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
|
|
|
TransactionFormGroup {
|
|
|
|
id: group1
|
|
|
|
headerText: root.commandTitle
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Continue"
|
|
|
|
footerText: qsTrId("continue")
|
2020-09-03 20:14:44 +00:00
|
|
|
|
|
|
|
AccountSelector {
|
|
|
|
id: selectFromAccount
|
|
|
|
accounts: walletModel.accounts
|
|
|
|
selectedAccount: walletModel.currentAccount
|
|
|
|
currency: walletModel.defaultCurrency
|
|
|
|
width: stack.width
|
2020-10-07 02:47:21 +00:00
|
|
|
label: {
|
|
|
|
return root.isRequested ?
|
|
|
|
qsTr("Receive on account") :
|
2020-10-12 11:44:04 +00:00
|
|
|
//% "From account"
|
2020-10-07 02:47:21 +00:00
|
|
|
qsTrId("from-account")
|
|
|
|
}
|
2020-09-03 20:14:44 +00:00
|
|
|
reset: function() {
|
|
|
|
accounts = Qt.binding(function() { return walletModel.accounts })
|
|
|
|
selectedAccount = Qt.binding(function() { return walletModel.currentAccount })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SeparatorWithIcon {
|
|
|
|
id: separator
|
|
|
|
anchors.top: selectFromAccount.bottom
|
|
|
|
anchors.topMargin: 19
|
2020-10-07 02:47:21 +00:00
|
|
|
icon.rotation: root.isRequested ? -90 : 90
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
2020-10-22 15:29:05 +00:00
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: addressRequiredInfo
|
|
|
|
anchors.right: selectRecipient.right
|
|
|
|
anchors.bottom: selectRecipient.top
|
|
|
|
anchors.bottomMargin: -Style.current.padding
|
|
|
|
text: qsTr("Address request required")
|
|
|
|
color: Style.current.danger
|
|
|
|
visible: addressRequiredValidator.isWarn
|
|
|
|
}
|
|
|
|
|
2020-09-03 20:14:44 +00:00
|
|
|
RecipientSelector {
|
|
|
|
id: selectRecipient
|
|
|
|
accounts: walletModel.accounts
|
|
|
|
contacts: profileModel.addedContacts
|
2020-10-16 13:21:57 +00:00
|
|
|
label: root.isRequested ?
|
|
|
|
qsTr("From") :
|
|
|
|
qsTr("To")
|
2020-09-03 20:14:44 +00:00
|
|
|
anchors.top: separator.bottom
|
|
|
|
anchors.topMargin: 10
|
|
|
|
width: stack.width
|
2020-10-22 15:29:05 +00:00
|
|
|
onSelectedRecipientChanged: {
|
|
|
|
addressRequiredValidator.address = root.isRequested ? selectFromAccount.selectedAccount.address : selectRecipient.selectedRecipient.address
|
|
|
|
}
|
2020-09-03 20:14:44 +00:00
|
|
|
reset: function() {
|
|
|
|
isValid = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TransactionFormGroup {
|
|
|
|
id: group2
|
|
|
|
headerText: root.commandTitle
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Preview"
|
|
|
|
footerText: qsTrId("preview")
|
2020-09-03 20:14:44 +00:00
|
|
|
|
|
|
|
AssetAndAmountInput {
|
|
|
|
id: txtAmount
|
|
|
|
selectedAccount: selectFromAccount.selectedAccount
|
|
|
|
defaultCurrency: walletModel.defaultCurrency
|
|
|
|
getFiatValue: walletModel.getFiatValue
|
|
|
|
getCryptoValue: walletModel.getCryptoValue
|
2020-10-28 07:44:09 +00:00
|
|
|
validateBalance: !root.isRequested
|
2020-09-03 20:14:44 +00:00
|
|
|
width: stack.width
|
|
|
|
reset: function() {
|
|
|
|
selectedAccount = Qt.binding(function() { return selectFromAccount.selectedAccount })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TransactionFormGroup {
|
|
|
|
id: group3
|
2020-10-16 13:21:57 +00:00
|
|
|
headerText: root.isRequested ?
|
|
|
|
qsTr("Preview") :
|
|
|
|
//% "Transaction preview"
|
|
|
|
qsTrId("transaction-preview")
|
2020-09-03 20:14:44 +00:00
|
|
|
footerText: root.finalButtonLabel
|
|
|
|
|
|
|
|
TransactionPreview {
|
|
|
|
id: pvwTransaction
|
|
|
|
width: stack.width
|
2020-10-16 13:21:57 +00:00
|
|
|
fromAccount: root.isRequested ? selectRecipient.selectedRecipient : selectFromAccount.selectedAccount
|
|
|
|
toAccount: root.isRequested ? selectFromAccount.selectedAccount : selectRecipient.selectedRecipient
|
2020-09-03 20:14:44 +00:00
|
|
|
asset: txtAmount.selectedAsset
|
|
|
|
amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount }
|
2020-10-22 15:29:05 +00:00
|
|
|
toWarn: addressRequiredValidator.isWarn
|
2020-09-03 20:14:44 +00:00
|
|
|
currency: walletModel.defaultCurrency
|
|
|
|
reset: function() {
|
2020-10-16 13:21:57 +00:00
|
|
|
fromAccount = Qt.binding(function() {
|
|
|
|
return root.isRequested ?
|
|
|
|
selectRecipient.selectedRecipient :
|
|
|
|
selectFromAccount.selectedAccount
|
|
|
|
})
|
|
|
|
toAccount = Qt.binding(function() {
|
|
|
|
return root.isRequested ?
|
|
|
|
selectFromAccount.selectedAccount :
|
|
|
|
selectRecipient.selectedRecipient
|
|
|
|
})
|
2020-09-03 20:14:44 +00:00
|
|
|
asset = Qt.binding(function() { return txtAmount.selectedAsset })
|
|
|
|
amount = Qt.binding(function() { return { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount } })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-22 15:29:05 +00:00
|
|
|
AddressRequiredValidator {
|
|
|
|
id: addressRequiredValidator
|
2020-09-03 20:14:44 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2020-10-22 15:29:05 +00:00
|
|
|
anchors.bottomMargin: Style.current.padding
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-10-07 02:47:21 +00:00
|
|
|
StatusRoundButton {
|
2020-09-03 20:14:44 +00:00
|
|
|
id: btnBack
|
|
|
|
anchors.left: parent.left
|
|
|
|
visible: !stack.isFirstGroup
|
2020-10-07 02:47:21 +00:00
|
|
|
icon.name: "arrow-right"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 16
|
|
|
|
rotation: 180
|
2020-09-03 20:14:44 +00:00
|
|
|
onClicked: {
|
|
|
|
stack.back()
|
|
|
|
}
|
|
|
|
}
|
2020-09-17 09:08:31 +00:00
|
|
|
StatusButton {
|
2020-09-03 20:14:44 +00:00
|
|
|
id: btnNext
|
|
|
|
anchors.right: parent.right
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Next"
|
2020-09-17 09:08:31 +00:00
|
|
|
text: qsTrId("next")
|
|
|
|
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) {
|
|
|
|
return root.sendChatCommand(selectFromAccount.selectedAccount.address,
|
|
|
|
txtAmount.selectedAmount,
|
2020-09-08 21:22:47 +00:00
|
|
|
txtAmount.selectedAsset.address,
|
|
|
|
txtAmount.selectedAsset.decimals)
|
2020-09-03 20:14:44 +00:00
|
|
|
}
|
|
|
|
stack.next()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|
|
|
|
|