2020-06-17 19:18:31 +00:00
import QtQuick 2.13
2020-07-30 05:18:54 +00:00
import QtQuick . Controls 2.13
2020-07-01 14:24:07 +00:00
import QtQuick . Dialogs 1.3
2020-05-29 15:43:37 +00:00
import "../../../../imports"
import "../../../../shared"
Item {
2020-06-26 16:08:51 +00:00
id: sendModalContent
2020-07-01 14:24:07 +00:00
property var closePopup: function ( ) { }
2020-06-26 16:08:51 +00:00
property alias amountInput: txtAmount
2020-07-01 14:24:07 +00:00
property alias passwordInput: txtPassword
2020-05-29 15:43:37 +00:00
2020-06-26 20:15:48 +00:00
property string passwordValidationError: ""
property string toValidationError: ""
property string amountValidationError: ""
2020-06-29 17:05:34 +00:00
function send ( ) {
if ( ! validate ( ) ) {
return ;
}
2020-07-30 05:18:54 +00:00
let result = walletModel . onSendTransaction ( selectFromAccount . selectedAccount . address ,
2020-08-06 07:25:53 +00:00
selectRecipient . selectedRecipient ,
2020-08-03 05:36:54 +00:00
selectAsset . selectedAsset . address ,
2020-06-29 17:05:34 +00:00
txtAmount . text ,
txtPassword . text )
2020-07-01 14:24:07 +00:00
if ( ! result . startsWith ( '0x' ) ) {
// It's an error
sendingError . text = result
return sendingError . open ( )
}
2020-07-21 07:15:04 +00:00
sendingSuccess . text = qsTr ( "Transaction sent to the blockchain. You can watch the progress on Etherscan: %2/%1" ) . arg ( result ) . arg ( walletModel . etherscanLink )
2020-07-01 14:24:07 +00:00
sendingSuccess . open ( )
2020-06-29 17:05:34 +00:00
}
2020-06-26 20:15:48 +00:00
function validate ( ) {
2020-08-12 09:05:12 +00:00
const isRecipientValid = selectRecipient . validate ( )
const isAssetAndAmountValid = txtAmount . validate ( )
2020-06-29 17:05:34 +00:00
if ( txtPassword . text === "" ) {
2020-07-06 20:39:55 +00:00
//% "You need to enter a password"
passwordValidationError = qsTrId ( "you-need-to-enter-a-password" )
2020-06-29 17:05:34 +00:00
} else if ( txtPassword . text . length < 4 ) {
2020-07-06 20:39:55 +00:00
//% "Password needs to be 4 characters or more"
passwordValidationError = qsTrId ( "password-needs-to-be-4-characters-or-more" )
2020-06-26 20:15:48 +00:00
} else {
passwordValidationError = ""
}
2020-08-12 09:05:12 +00:00
return passwordValidationError === "" && toValidationError === "" && amountValidationError === "" && isRecipientValid && isAssetAndAmountValid
2020-06-26 20:15:48 +00:00
}
2020-06-26 16:08:51 +00:00
anchors.left: parent . left
anchors.right: parent . right
2020-05-29 15:43:37 +00:00
2020-07-01 14:24:07 +00:00
MessageDialog {
id: sendingError
title: "Error sending the transaction"
icon: StandardIcon . Critical
standardButtons: StandardButton . Ok
}
MessageDialog {
id: sendingSuccess
2020-07-06 20:39:55 +00:00
//% "Success sending the transaction"
title: qsTrId ( "success-sending-the-transaction" )
2020-07-01 14:24:07 +00:00
icon: StandardIcon . NoIcon
standardButtons: StandardButton . Ok
onAccepted: {
closePopup ( )
}
}
2020-08-04 11:10:09 +00:00
AssetAndAmountInput {
2020-08-12 09:05:12 +00:00
id: txtAmount
selectedAccount: walletModel . currentAccount
defaultCurrency: walletModel . defaultCurrency
anchors.top: parent . top
getFiatValue: walletModel . getFiatValue
getCryptoValue: walletModel . getCryptoValue
2020-06-29 17:05:34 +00:00
}
2020-07-30 05:18:54 +00:00
AccountSelector {
id: selectFromAccount
accounts: walletModel . accounts
2020-08-06 02:33:30 +00:00
currency: walletModel . defaultCurrency
2020-08-04 11:10:09 +00:00
anchors.top: txtAmount . bottom
2020-07-02 15:14:31 +00:00
anchors.topMargin: Style . current . padding
2020-06-26 20:02:05 +00:00
anchors.left: parent . left
2020-07-30 05:18:54 +00:00
anchors.right: parent . right
2020-08-10 18:44:42 +00:00
onSelectedAccountChanged: {
2020-08-12 09:05:12 +00:00
txtAmount . selectedAccount = selectFromAccount . selectedAccount
2020-08-04 11:10:09 +00:00
}
2020-06-26 20:02:05 +00:00
}
2020-08-06 07:25:53 +00:00
RecipientSelector {
id: selectRecipient
accounts: walletModel . accounts
contacts: profileModel . addedContacts
label: qsTr ( "Recipient" )
2020-07-30 05:18:54 +00:00
anchors.top: selectFromAccount . bottom
2020-07-02 15:14:31 +00:00
anchors.topMargin: Style . current . padding
2020-08-06 07:25:53 +00:00
anchors.left: parent . left
anchors.right: parent . right
2020-05-29 15:43:37 +00:00
}
2020-06-26 16:08:51 +00:00
Input {
id: txtPassword
2020-07-06 20:39:55 +00:00
//% "Password"
label: qsTrId ( "password" )
//% "Enter Password"
placeholderText: qsTrId ( "biometric-auth-login-ios-fallback-label" )
2020-08-06 07:25:53 +00:00
anchors.top: selectRecipient . bottom
2020-07-02 15:14:31 +00:00
anchors.topMargin: Style . current . padding
2020-06-26 16:08:51 +00:00
textField.echoMode: TextInput . Password
2020-06-26 20:15:48 +00:00
validationError: passwordValidationError
2020-05-29 15:43:37 +00:00
}
}
/ * # # ^ # #
Designer {
2020-06-26 20:02:05 +00:00
D { i: 0 ; autoSize: true ; formeditorColor: "#ffffff" ; height: 480 ; width: 640 }
2020-05-29 15:43:37 +00:00
}
# # ^ # # * /