2020-06-17 15:18:31 -04:00
|
|
|
import QtQuick 2.13
|
2020-05-29 11:43:37 -04:00
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
|
|
|
|
Item {
|
2020-06-26 12:08:51 -04:00
|
|
|
id: sendModalContent
|
|
|
|
property alias amountInput: txtAmount
|
|
|
|
property alias amountText: txtAmount.text
|
|
|
|
property alias toText: txtTo.text
|
|
|
|
property alias passwordText: txtPassword.text
|
2020-06-26 15:43:20 -04:00
|
|
|
property var accounts
|
2020-05-29 13:53:39 -04:00
|
|
|
property string defaultAccount: "0x1234"
|
2020-06-26 16:02:05 -04:00
|
|
|
property int selectedAccountIndex: 0
|
2020-06-29 10:33:21 -04:00
|
|
|
property string selectedAccountAddress: accounts && accounts.length ? accounts[selectedAccountIndex].address : ""
|
|
|
|
property string selectedAccountName: accounts && accounts.length ? accounts[selectedAccountIndex].name : ""
|
|
|
|
property string selectedAccountIconColor: accounts && accounts.length ? accounts[selectedAccountIndex].iconColor : ""
|
|
|
|
|
2020-05-29 11:43:37 -04:00
|
|
|
|
2020-06-26 16:15:48 -04:00
|
|
|
property string passwordValidationError: ""
|
|
|
|
property string toValidationError: ""
|
|
|
|
property string amountValidationError: ""
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
if (passwordText === "") {
|
|
|
|
passwordValidationError = qsTr("You need to enter a password")
|
|
|
|
} else if (passwordText.length < 4) {
|
|
|
|
passwordValidationError = qsTr("Password needs to be 4 characters or more")
|
|
|
|
} else {
|
|
|
|
passwordValidationError = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toText === "") {
|
|
|
|
toValidationError = qsTr("You need to enter a destination address")
|
|
|
|
} else if (!Utils.isAddress(toText)) {
|
|
|
|
toValidationError = qsTr("This needs to be a valid address (starting with 0x)")
|
|
|
|
} else {
|
|
|
|
toValidationError = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amountText === "") {
|
|
|
|
amountValidationError = qsTr("You need to enter an amount")
|
|
|
|
} else if (isNaN(amountText)) {
|
|
|
|
amountValidationError = qsTr("This needs to be a number")
|
|
|
|
// TODO check balance?
|
|
|
|
} else {
|
|
|
|
amountValidationError = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return passwordValidationError === "" && toValidationError === "" && amountValidationError === ""
|
|
|
|
}
|
|
|
|
|
2020-06-26 12:08:51 -04:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-05-29 11:43:37 -04:00
|
|
|
|
2020-06-26 12:08:51 -04:00
|
|
|
Input {
|
|
|
|
id: txtAmount
|
|
|
|
label: qsTr("Amount")
|
|
|
|
icon: "../../../img/token-icons/eth.svg"
|
2020-05-29 11:43:37 -04:00
|
|
|
anchors.top: parent.top
|
2020-06-26 12:08:51 -04:00
|
|
|
placeholderText: qsTr("Enter ETH")
|
2020-06-26 16:15:48 -04:00
|
|
|
validationError: amountValidationError
|
2020-05-29 11:43:37 -04:00
|
|
|
}
|
|
|
|
|
2020-06-26 13:29:03 -04:00
|
|
|
Select {
|
2020-06-26 12:08:51 -04:00
|
|
|
id: txtFrom
|
2020-06-26 16:02:05 -04:00
|
|
|
iconHeight: 12
|
|
|
|
iconWidth: 12
|
|
|
|
icon: "../../../img/walletIcon.svg"
|
2020-06-29 10:33:21 -04:00
|
|
|
iconColor: selectedAccountIconColor
|
2020-06-26 12:08:51 -04:00
|
|
|
label: qsTr("From account")
|
|
|
|
anchors.top: txtAmount.bottom
|
2020-05-29 11:43:37 -04:00
|
|
|
anchors.topMargin: Theme.padding
|
2020-06-29 10:33:21 -04:00
|
|
|
selectedText: selectedAccountName
|
2020-06-26 16:02:05 -04:00
|
|
|
selectOptions: sendModalContent.accounts.map(function (account, index) {
|
2020-06-26 15:43:20 -04:00
|
|
|
return {
|
|
|
|
text: account.name,
|
2020-06-26 13:29:03 -04:00
|
|
|
onClicked: function () {
|
2020-06-26 16:02:05 -04:00
|
|
|
selectedAccountIndex = index
|
2020-06-26 13:29:03 -04:00
|
|
|
}
|
|
|
|
}
|
2020-06-26 15:43:20 -04:00
|
|
|
})
|
2020-05-29 11:43:37 -04:00
|
|
|
}
|
|
|
|
|
2020-06-26 16:02:05 -04:00
|
|
|
StyledText {
|
|
|
|
id: textSelectAccountAddress
|
2020-06-29 10:33:21 -04:00
|
|
|
text: selectedAccountAddress
|
2020-06-26 16:02:05 -04:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 2
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
anchors.top: txtFrom.bottom
|
|
|
|
font.pixelSize: 12
|
|
|
|
color: Theme.darkGrey
|
|
|
|
}
|
|
|
|
|
2020-06-26 12:08:51 -04:00
|
|
|
Input {
|
|
|
|
id: txtTo
|
|
|
|
label: qsTr("Recipient")
|
|
|
|
text: defaultAccount
|
|
|
|
placeholderText: qsTr("Send to")
|
2020-06-26 16:02:05 -04:00
|
|
|
anchors.top: textSelectAccountAddress.bottom
|
2020-06-26 12:08:51 -04:00
|
|
|
anchors.topMargin: Theme.padding
|
2020-06-26 16:15:48 -04:00
|
|
|
validationError: toValidationError
|
2020-05-29 11:43:37 -04:00
|
|
|
}
|
|
|
|
|
2020-06-26 12:08:51 -04:00
|
|
|
Input {
|
|
|
|
id: txtPassword
|
|
|
|
label: qsTr("Password")
|
|
|
|
placeholderText: qsTr("Enter Password")
|
|
|
|
anchors.top: txtTo.bottom
|
|
|
|
anchors.topMargin: Theme.padding
|
|
|
|
textField.echoMode: TextInput.Password
|
2020-06-26 16:15:48 -04:00
|
|
|
validationError: passwordValidationError
|
2020-05-29 11:43:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-06-26 16:02:05 -04:00
|
|
|
D{i:0;autoSize:true;formeditorColor:"#ffffff";height:480;width:640}
|
2020-05-29 11:43:37 -04:00
|
|
|
}
|
|
|
|
##^##*/
|