wowlet/src/vr/qml/wallet/send/SendPagePIN.qml

188 lines
4.8 KiB
QML
Raw Normal View History

2021-04-05 12:37:41 +01:00
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import "../../common"
ColumnLayout {
id: root
Layout.fillWidth: true
2021-04-09 17:00:12 +01:00
property string pin: ""
2021-04-05 12:37:41 +01:00
MyText {
Layout.fillWidth: true
wrap: true
2021-04-08 02:40:44 +01:00
fontColor: Style.fontColorBright
2021-04-05 12:37:41 +01:00
text: "Enter a 4 digit PIN and wait for it to resolve."
}
RowLayout {
Layout.topMargin: 30
Layout.fillWidth: true
spacing: 40
ColumnLayout {
Layout.preferredWidth: 320
Layout.preferredHeight: 400
MyNumPad {
id: numPad
2021-04-09 17:00:12 +01:00
onButtonPress: {
root.pin += val;
if(root.pin.length === 4 && root.pin !== "0000") {
return addressLookup();
2021-04-05 12:37:41 +01:00
}
}
}
Rectangle {
Layout.fillHeight: true
Layout.preferredWidth: parent.Layout.preferredWidth
color: "transparent"
}
}
ColumnLayout {
Layout.preferredHeight: 400
Layout.preferredWidth: 390
Text {
id: codeDisplay
Layout.preferredWidth: 390
visible: true
2021-04-09 17:00:12 +01:00
text: (root.pin[0] || ".") + " " + (root.pin[1] || ".") + " " + (root.pin[2] || ".") + " " + (root.pin[3] || ".");
2021-04-08 02:40:44 +01:00
color: Style.fontColor
2021-04-05 12:37:41 +01:00
font.bold: true
font.pointSize: 60
2021-04-05 12:37:41 +01:00
leftPadding: 20
rightPadding: 20
Rectangle {
z: parent.z - 1
anchors.fill: parent
color: "black"
}
}
Rectangle {
color: "transparent"
Layout.fillHeight: true
Layout.preferredWidth: parent.Layout.preferredWidth
}
}
Rectangle {
2021-04-08 02:40:44 +01:00
color: Style.fontColorDimmed
2021-04-05 12:37:41 +01:00
width: 1
Layout.fillHeight: true
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
// Idle container
ColumnLayout {
id: idleContainer
visible: true
spacing: 30
Layout.fillWidth: true
MyText {
fontSize: 22
2021-04-08 02:40:44 +01:00
fontColor: Style.fontColorBright
2021-04-05 12:37:41 +01:00
text: "Waiting on input..."
}
}
// Loading container
ColumnLayout {
id: loadingContainer
visible: false
spacing: 10
Layout.fillWidth: true
MyText {
fontSize: 22
2021-04-08 02:40:44 +01:00
fontColor: Style.fontColorBright
2021-04-05 12:37:41 +01:00
text: "Looking up address..."
}
RowLayout {
spacing: 30
Layout.topMargin: 20
Layout.fillWidth: true
MyText {
fontBold: true
2021-04-08 02:40:44 +01:00
fontColor: Style.fontColorBright
2021-04-05 12:37:41 +01:00
text: "Code:"
}
MyText {
2021-04-09 17:00:12 +01:00
text: root.pin
2021-04-05 12:37:41 +01:00
}
}
}
}
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
2021-04-09 17:00:12 +01:00
function addressLookup() {
console.log("addressLookup()");
2021-04-05 12:37:41 +01:00
idleContainer.visible = false;
loadingContainer.visible = true;
numPad.enabled = false;
2021-04-09 17:00:12 +01:00
try {
ctx.onLookupReceivingPIN(root.pin);
} catch(err){
console.log("ctx.onLookupReceivingPIN() ignored")
}
2021-04-05 12:37:41 +01:00
}
function onPageCompleted(previousView) {
reset();
}
function reset() {
2021-04-09 17:00:12 +01:00
console.log("SendPagePin reset()");
2021-04-05 12:37:41 +01:00
// reset state
2021-04-09 17:00:12 +01:00
root.pin = "";
2021-04-05 12:37:41 +01:00
idleContainer.visible = true;
loadingContainer.visible = false;
sendStateController.destinationAddress = "";
numPad.enabled = true;
numPad.reset();
}
2021-04-06 01:20:42 +01:00
Connections {
target: ctx
function onPinLookupReceived(address, pin) {
console.log("onPinLookupReceived", address);
2021-04-09 17:00:12 +01:00
if(pin === root.pin) {
2021-04-06 01:20:42 +01:00
sendStateController.destinationAddress = address;
sendStateView.state = "transferPage";
} else {
console.log("PIN lookup received but we timed out already, disregard.") // undefined behavior
}
}
function onPinLookupErrorReceived() {
console.log("onPinLookupErrorReceived");
messagePopup.showMessage("Lookup failed", "Error getting address.")
reset();
}
}
2021-04-05 12:37:41 +01:00
}