status-desktop/ui/shared/BalanceValidator.qml
Alexandra Betouni 4ee21ada05 feat(desktop) Added image function in Style
Introduced Style.svg() Style.png() Style.emoji() and
Style.icon() in Style.qml. Those should be used to
set the source in Images instead of using relative
paths. Usage:
Image {
   source: Style.svg("check)
   ....

Also moved all Singletons inside a new "utils"
folder and made it a QML module, to use
import utils 1.0 instead of relative paths

Closes #3678
2021-09-28 15:28:00 -04:00

58 lines
1.5 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import utils 1.0
import "./status"
Column {
id: root
anchors.horizontalCenter: parent.horizontalCenter
visible: !isValid
spacing: 5
property var account
property double amount
property var asset
property bool isValid: false
property alias errorMessage: txtValidationError.text
onAccountChanged: validate()
onAmountChanged: validate()
onAssetChanged: validate()
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
}
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
//% "Insufficient balance"
text: qsTrId("insufficient-balance")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 13
height: 18
color: Style.current.danger
}
}