2020-10-16 13:21:57 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import "../imports"
|
|
|
|
import "./status"
|
|
|
|
|
2020-10-22 12:06:35 +00:00
|
|
|
Column {
|
2020-10-16 13:21:57 +00:00
|
|
|
id: root
|
2020-10-22 12:06:35 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
visible: !isValid
|
|
|
|
spacing: 5
|
|
|
|
|
2020-10-16 13:21:57 +00:00
|
|
|
property var account
|
|
|
|
property double amount
|
|
|
|
property var asset
|
2020-10-22 12:06:35 +00:00
|
|
|
property bool isValid: false
|
2020-10-16 13:21:57 +00:00
|
|
|
property var reset: function() {}
|
2020-10-22 12:06:35 +00:00
|
|
|
property alias errorMessage: txtValidationError.text
|
2020-10-16 13:21:57 +00:00
|
|
|
|
|
|
|
onAccountChanged: validate()
|
|
|
|
onAmountChanged: validate()
|
|
|
|
onAssetChanged: validate()
|
|
|
|
|
|
|
|
function resetInternal() {
|
|
|
|
account = undefined
|
|
|
|
amount = 0
|
|
|
|
asset = undefined
|
2020-10-22 12:06:35 +00:00
|
|
|
isValid = false
|
2020-10-16 13:21:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
let isValid = true
|
|
|
|
if (!(account && account.assets && asset && amount > 0)) {
|
|
|
|
return root.isValid
|
|
|
|
}
|
|
|
|
const currAcctAsset = Utils.findAssetBySymbol(account.assets, asset.symbol)
|
|
|
|
|
|
|
|
if (currAcctAsset && currAcctAsset.value < amount) {
|
|
|
|
isValid = false
|
|
|
|
}
|
|
|
|
root.isValid = isValid
|
|
|
|
return isValid
|
|
|
|
}
|
2020-10-22 12:06:35 +00:00
|
|
|
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
|
2020-10-16 13:21:57 +00:00
|
|
|
text: qsTr("Insufficient balance")
|
2020-10-22 12:06:35 +00:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
font.pixelSize: 13
|
|
|
|
height: 18
|
|
|
|
color: Style.current.danger
|
2020-10-16 13:21:57 +00:00
|
|
|
}
|
|
|
|
}
|