status-desktop/ui/shared/TransactionSigner.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

118 lines
3.8 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../imports"
import "../shared/status"
Item {
id: root
height: signingPhraseItem.height + signingPhrase.height + txtPassword.height + Style.current.smallPadding + Style.current.bigPadding
property alias signingPhrase: signingPhrase.text
property string enteredPassword
property alias validationError: txtPassword.validationError
//% "You need to enter a password"
property string noInputErrorMessage: qsTrId("you-need-to-enter-a-password")
//% "Password needs to be 4 characters or more"
property string invalidInputErrorMessage: qsTrId("password-needs-to-be-4-characters-or-more")
property bool isValid: false
function forceActiveFocus(reason) {
txtPassword.forceActiveFocus(reason)
}
function validate() {
txtPassword.validationError = ""
const noInput = txtPassword.text === ""
if (noInput) {
txtPassword.validationError = noInputErrorMessage
} else if (txtPassword.text.length < 4) {
txtPassword.validationError = invalidInputErrorMessage
}
isValid = txtPassword.validationError === ""
return isValid
}
Item {
id: signingPhraseItem
anchors.horizontalCenter: parent.horizontalCenter
height: labelSigningPhrase.height
width: labelSigningPhrase.width + infoButton.width + infoButton.anchors.leftMargin
StyledText {
id: labelSigningPhrase
color: Style.current.secondaryText
font.pixelSize: 15
//% "Signing phrase"
text: qsTrId("signing-phrase")
}
StatusRoundButton {
id: infoButton
anchors.left: labelSigningPhrase.right
anchors.leftMargin: 7
anchors.verticalCenter: parent.verticalCenter
width: 13
height: 13
icon.width: width
icon.height: height
icon.name: "info"
StatusToolTip {
visible: infoButton.hovered
width: 337
//% "Signing phrase is a 3 word combination that displayed when you entered the wallet on this device for the first time."
text: qsTrId("signing-phrase-is-a-3-word-combination-that-displayed-when-you-entered-the-wallet-on-this-device-for-the-first-time-")
}
}
}
StyledText {
id: signingPhrase
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: signingPhraseItem.bottom
anchors.topMargin: Style.current.smallPadding
font.pixelSize: 15
text: root.signingPhrase
}
StatusRoundButton {
id: passwordInfoButton
anchors.left: parent.left
anchors.leftMargin: 67
anchors.top: txtPassword.top
anchors.topMargin: 2
width: 13
height: 13
icon.width: width
icon.height: height
icon.name: "info"
StatusToolTip {
visible: passwordInfoButton.hovered
width: 224
//% "Enter the password you use to unlock this device"
text: qsTrId("enter-the-password-you-use-to-unlock-this-device")
}
}
Input {
id: txtPassword
anchors.top: signingPhrase.bottom
anchors.topMargin: Style.current.bigPadding
focus: true
customHeight: 56
//% "Password"
label: qsTrId("password")
//% "Enter Password"
placeholderText: qsTrId("enter-password")
textField.echoMode: TextInput.Password
validationErrorAlignment: TextEdit.AlignRight
validationErrorTopMargin: 8
onTextChanged: {
if(root.validate()) {
root.enteredPassword = this.text
}
}
}
}