mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-23 03:58:49 +00:00
fix(wallet): make it possible to send a 0 tx with a warning
Fixes #2652
This commit is contained in:
parent
b99300bf10
commit
2716abf096
@ -59,6 +59,7 @@ Theme {
|
|||||||
property color primary: blue
|
property color primary: blue
|
||||||
property color danger: red
|
property color danger: red
|
||||||
property color success: green
|
property color success: green
|
||||||
|
property color warning: orange
|
||||||
property color primaryMenuItemHover: blue
|
property color primaryMenuItemHover: blue
|
||||||
property color primaryMenuItemTextHover: almostBlack
|
property color primaryMenuItemTextHover: almostBlack
|
||||||
property color backgroundTertiary: tenPercentBlue
|
property color backgroundTertiary: tenPercentBlue
|
||||||
|
@ -59,6 +59,7 @@ Theme {
|
|||||||
property color primary: blue
|
property color primary: blue
|
||||||
property color danger: red
|
property color danger: red
|
||||||
property color success: green
|
property color success: green
|
||||||
|
property color warning: orange
|
||||||
property color primaryMenuItemHover: blue
|
property color primaryMenuItemHover: blue
|
||||||
property color primaryMenuItemTextHover: white
|
property color primaryMenuItemTextHover: white
|
||||||
property color backgroundTertiary: tenPercentBlue
|
property color backgroundTertiary: tenPercentBlue
|
||||||
|
@ -7,8 +7,7 @@ import "../imports"
|
|||||||
Item {
|
Item {
|
||||||
//% "Insufficient balance"
|
//% "Insufficient balance"
|
||||||
property string balanceErrorMessage: qsTrId("insufficient-balance")
|
property string balanceErrorMessage: qsTrId("insufficient-balance")
|
||||||
//% "Must be greater than 0"
|
property string greaterThanOrEqualTo0ErrorMessage: qsTr("Must be greater than or equal to 0")
|
||||||
property string greaterThan0ErrorMessage: qsTrId("must-be-greater-than-0")
|
|
||||||
//% "This needs to be a number"
|
//% "This needs to be a number"
|
||||||
property string invalidInputErrorMessage: qsTrId("this-needs-to-be-a-number")
|
property string invalidInputErrorMessage: qsTrId("this-needs-to-be-a-number")
|
||||||
//% "Please enter an amount"
|
//% "Please enter an amount"
|
||||||
@ -23,6 +22,8 @@ Item {
|
|||||||
property bool isDirty: false
|
property bool isDirty: false
|
||||||
property bool validateBalance: true
|
property bool validateBalance: true
|
||||||
property bool isValid: false
|
property bool isValid: false
|
||||||
|
property string validationError
|
||||||
|
property var formattedInputValue
|
||||||
|
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ Item {
|
|||||||
let error = ""
|
let error = ""
|
||||||
const hasTyped = checkDirty ? isDirty : true
|
const hasTyped = checkDirty ? isDirty : true
|
||||||
const balance = parseFloat(txtBalance.text || "0.00")
|
const balance = parseFloat(txtBalance.text || "0.00")
|
||||||
const input = parseFloat(inputAmount.text || "0.00")
|
formattedInputValue = parseFloat(inputAmount.text || "0.00")
|
||||||
const noInput = inputAmount.text === ""
|
const noInput = inputAmount.text === ""
|
||||||
if (noInput && hasTyped) {
|
if (noInput && hasTyped) {
|
||||||
error = noInputErrorMessage
|
error = noInputErrorMessage
|
||||||
@ -43,19 +44,19 @@ Item {
|
|||||||
} else if (isNaN(inputAmount.text)) {
|
} else if (isNaN(inputAmount.text)) {
|
||||||
error = invalidInputErrorMessage
|
error = invalidInputErrorMessage
|
||||||
isValid = false
|
isValid = false
|
||||||
} else if (input <= 0.00 && hasTyped) {
|
} else if (formattedInputValue < 0.00 && hasTyped) {
|
||||||
error = greaterThan0ErrorMessage
|
error = greaterThanOrEqualTo0ErrorMessage
|
||||||
isValid = false
|
isValid = false
|
||||||
} else if (validateBalance && input > balance && !noInput) {
|
} else if (validateBalance && formattedInputValue > balance && !noInput) {
|
||||||
error = balanceErrorMessage
|
error = balanceErrorMessage
|
||||||
isValid = false
|
isValid = false
|
||||||
}
|
}
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
inputAmount.validationError = error
|
root.validationError = error
|
||||||
txtBalanceDesc.color = Style.current.danger
|
txtBalanceDesc.color = Style.current.danger
|
||||||
txtBalance.color = Style.current.danger
|
txtBalance.color = Style.current.danger
|
||||||
} else {
|
} else {
|
||||||
inputAmount.validationError = ""
|
root.validationError = ""
|
||||||
txtBalanceDesc.color = Style.current.secondaryText
|
txtBalanceDesc.color = Style.current.secondaryText
|
||||||
txtBalance.color = Qt.binding(function() { return txtBalance.hovered ? Style.current.textColor : Style.current.secondaryText })
|
txtBalance.color = Qt.binding(function() { return txtBalance.hovered ? Style.current.textColor : Style.current.secondaryText })
|
||||||
}
|
}
|
||||||
@ -127,6 +128,17 @@ Item {
|
|||||||
customHeight: 56
|
customHeight: 56
|
||||||
validationErrorAlignment: TextEdit.AlignRight
|
validationErrorAlignment: TextEdit.AlignRight
|
||||||
validationErrorTopMargin: 8
|
validationErrorTopMargin: 8
|
||||||
|
validationErrorColor: formattedInputValue === 0 ? Style.current.warning : Style.current.danger
|
||||||
|
validationError: {
|
||||||
|
if (root.validationError) {
|
||||||
|
return root.validationError
|
||||||
|
}
|
||||||
|
if (formattedInputValue === 0) {
|
||||||
|
return qsTr("The amount is 0. Proceed only if this is desired.")
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
Keys.onReleased: {
|
Keys.onReleased: {
|
||||||
let amount = inputAmount.text.trim()
|
let amount = inputAmount.text.trim()
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ Item {
|
|||||||
property string validationError: ""
|
property string validationError: ""
|
||||||
property alias validationErrorAlignment: validationErrorText.horizontalAlignment
|
property alias validationErrorAlignment: validationErrorText.horizontalAlignment
|
||||||
property int validationErrorTopMargin: 1
|
property int validationErrorTopMargin: 1
|
||||||
|
property color validationErrorColor: Style.current.danger
|
||||||
property string label: ""
|
property string label: ""
|
||||||
readonly property bool hasLabel: label !== ""
|
readonly property bool hasLabel: label !== ""
|
||||||
property color bgColor: Style.current.inputBackground
|
property color bgColor: Style.current.inputBackground
|
||||||
@ -70,7 +71,7 @@ Item {
|
|||||||
border.width: (!!validationError || inputValue.focus) ? 1 : 0
|
border.width: (!!validationError || inputValue.focus) ? 1 : 0
|
||||||
border.color: {
|
border.color: {
|
||||||
if (!!validationError) {
|
if (!!validationError) {
|
||||||
return Style.current.danger
|
return validationErrorColor
|
||||||
}
|
}
|
||||||
if (!inputBox.readOnly && inputValue.focus) {
|
if (!inputBox.readOnly && inputValue.focus) {
|
||||||
return Style.current.inputBorderFocus
|
return Style.current.inputBorderFocus
|
||||||
@ -180,7 +181,7 @@ Item {
|
|||||||
readOnly: true
|
readOnly: true
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
height: 16
|
height: 16
|
||||||
color: Style.current.danger
|
color: validationErrorColor
|
||||||
width: inputRectangle.width
|
width: inputRectangle.width
|
||||||
wrapMode: TextEdit.Wrap
|
wrapMode: TextEdit.Wrap
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ Item {
|
|||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: profileNotFoundMessage
|
id: profileNotFoundMessage
|
||||||
color: Style.current.darkGrey
|
color: Style.current.secondaryText
|
||||||
visible: root.showProfileNotFoundMessage
|
visible: root.showProfileNotFoundMessage
|
||||||
font.pixelSize: 15
|
font.pixelSize: 15
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user