status-desktop/ui/shared/SendToContractWarning.qml
emizzle e0e1487643 refactor: replace transaction modal reset functionality
The transaction component's `reset` functionality was meant ot reset a form when the modal was closed. It was difficult to manage and added extra overhead for each additional transaction modal created.

Instead of using reset functions, we can use Loaders to load and destroy the modal's as they are opened and closed. We do not need to keep them in memory and then also reset their functions. It creates a smaller memory footprint to destroy the object and reload on open.

feat: load gas prediction prices asynchronously
2020-11-26 11:17:24 -05:00

62 lines
2.0 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../imports"
import "./"
Item {
id: root
anchors.left: parent.left
anchors.right: parent.right
property string sendToContractWarningMessage: qsTr("Tokens will be sent directly to a contract address, which may result in a loss of funds. To transfer ERC-20 tokens, ensure the recipient address is the address of the destination wallet.")
property var selectedRecipient
property bool isValid: true
onSelectedRecipientChanged: validate()
function validate() {
let isValid = true
if (!(selectedRecipient && selectedRecipient.address)) {
return root.isValid
}
txtValidationError.text = ""
if (walletModel.isKnownTokenContract(selectedRecipient.address)) {
// do not set isValid = false here because it would make the
// TransactionStackGroup invalid and therefore not let the user
// continue in the modal
txtValidationError.text = sendToContractWarningMessage
}
return isValid
}
Column {
id: colValidation
anchors.horizontalCenter: parent.horizontalCenter
visible: txtValidationError.text !== ""
spacing: 5
SVGImage {
id: imgExclamation
width: 13.33
height: 13.33
sourceSize.height: height * 2
sourceSize.width: width * 2
anchors.horizontalCenter: parent.horizontalCenter
fillMode: Image.PreserveAspectFit
source: "../app/img/exclamation_outline.svg"
}
StyledText {
id: txtValidationError
text: ""
width: root.width
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 13
color: Style.current.danger
lineHeight: 18
lineHeightMode: Text.FixedHeight
wrapMode: Text.WordWrap
}
}
}