status-desktop/ui/app/AppLayouts/Chat/popups/ChatCommandModal.qml

191 lines
6.8 KiB
QML
Raw Normal View History

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 utils 1.0
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Popups 0.1
import StatusQ.Controls 0.1 as StatusQControls
import "../../../../shared/panels"
import "../../../../shared/controls"
import "../../../../shared/views"
StatusModal {
2020-09-03 20:14:44 +00:00
property string commandTitle: "Send"
property string finalButtonLabel: "Request address"
property var sendChatCommand: function () {}
property bool isRequested: false
2020-09-03 20:14:44 +00:00
id: root
anchors.centerIn: parent
header.title: root.commandTitle
2020-09-03 20:14:44 +00:00
height: 504
property alias selectRecipient: selectRecipient
2020-09-03 20:14:44 +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
//% "Continue"
footerText: qsTrId("continue")
StatusQControls.StatusAccountSelector {
id: selectFromAccount
accounts: walletModel.accountsView.accounts
selectedAccount: {
const currAcc = walletModel.accountsView.currentAccount
if (currAcc.walletType !== Constants.watchWalletType) {
return currAcc
}
return null
}
currency: walletModel.balanceView.defaultCurrency
width: stack.width
label: {
return root.isRequested ?
//% "Receive on account"
qsTrId("receive-on-account") :
//% "From account"
qsTrId("from-account")
}
}
SeparatorWithIcon {
id: separator
anchors.top: selectFromAccount.bottom
anchors.topMargin: 19
icon.rotation: root.isRequested ? -90 : 90
}
StatusBaseText {
id: addressRequiredInfo
anchors.right: selectRecipient.right
anchors.bottom: selectRecipient.top
anchors.bottomMargin: -Style.current.padding
//% "Address request required"
text: qsTrId("address-request-required")
color: Theme.palette.dangerColor1
visible: addressRequiredValidator.isWarn
}
RecipientSelector {
id: selectRecipient
accounts: walletModel.accountsView.accounts
contacts: profileModel.contacts.addedContacts
label: root.isRequested ?
//% "From"
qsTrId("from") :
//% "To"
qsTrId("to")
anchors.top: separator.bottom
anchors.topMargin: 10
width: stack.width
onSelectedRecipientChanged: {
addressRequiredValidator.address = root.isRequested ? selectFromAccount.selectedAccount.address : selectRecipient.selectedRecipient.address
}
}
2020-09-03 20:14:44 +00:00
}
TransactionFormGroup {
id: group2
headerText: root.commandTitle
2021-02-18 16:36:05 +00:00
//% "Preview"
footerText: qsTrId("preview")
AssetAndAmountInput {
id: txtAmount
selectedAccount: selectFromAccount.selectedAccount
defaultCurrency: walletModel.balanceView.defaultCurrency
getFiatValue: walletModel.balanceView.getFiatValue
getCryptoValue: walletModel.balanceView.getCryptoValue
validateBalance: !root.isRequested
width: stack.width
}
2020-09-03 20:14:44 +00:00
}
TransactionFormGroup {
id: group3
headerText: root.isRequested ?
//% "Preview"
qsTrId("preview") :
//% "Transaction preview"
qsTrId("transaction-preview")
footerText: root.finalButtonLabel
2020-09-03 20:14:44 +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
currency: walletModel.balanceView.defaultCurrency
}
AddressRequiredValidator {
id: addressRequiredValidator
anchors.bottom: parent.bottom
anchors.bottomMargin: Style.current.padding
}
2020-09-03 20:14:44 +00:00
}
}
}
leftButtons: [
StatusQControls.StatusRoundButton {
2020-09-03 20:14:44 +00:00
visible: !stack.isFirstGroup
icon.name: "arrow-right"
icon.width: 20
icon.height: 16
rotation: 180
2020-09-03 20:14:44 +00:00
onClicked: {
stack.back()
}
}
]
rightButtons: [
StatusQControls.StatusButton {
2020-09-03 20:14:44 +00:00
id: btnNext
//% "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,
txtAmount.selectedAsset.address,
txtAmount.selectedAsset.decimals)
2020-09-03 20:14:44 +00:00
}
stack.next()
}
}
}
]
2020-09-03 20:14:44 +00:00
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/