117 lines
3.8 KiB
QML
117 lines
3.8 KiB
QML
import QtQuick;
|
|
import QtQuick.Controls.Basic as QQC2
|
|
import Flowee.org.pay;
|
|
import "../Flowee" as Flowee;
|
|
import "../mobile" as Mobile;
|
|
import Flowee.org.pay.backup;
|
|
|
|
Mobile.Page {
|
|
id: root
|
|
headerText: qsTr("Create NFC backup")
|
|
required property QtObject pageData
|
|
|
|
Item {
|
|
id: data
|
|
property bool writeSuccess: false
|
|
NFC {
|
|
id: nfc
|
|
account: root.pageData
|
|
onNfcStatusChanged: {
|
|
let status = nfcStatus
|
|
if (status == Wallet.NFC_WriteSuccess) {
|
|
data.writeSuccess = true
|
|
errorLabel.writeError = 0;
|
|
closeButton.isMainButton = true
|
|
}
|
|
else if (status != Wallet.NFC_WriteWait) {
|
|
errorLabel.writeError = status;
|
|
}
|
|
}
|
|
}
|
|
Timer {
|
|
interval: 200
|
|
running: nfc.nfcStatus != Wallet.NFC_Disabled
|
|
repeat: false
|
|
onTriggered: nfc.start()
|
|
}
|
|
}
|
|
Flowee.Label {
|
|
width: parent.width
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
text: qsTr("Store your wallet seed on an simple NFC tag for offline backup. A seed can be used to re-start your wallet and get back any money in it.")
|
|
}
|
|
Flowee.Label {
|
|
text: nfc.nfcStatus
|
|
anchors.right: parent.right
|
|
anchors.bottom: parent.bottom
|
|
opacity: 0.6
|
|
}
|
|
|
|
Image {
|
|
id: tag
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
y: 200
|
|
source: "qrc:/backup-sync/nfc-tag.svg"
|
|
width: 90
|
|
height: 90
|
|
}
|
|
Flowee.Label {
|
|
id: infoLabel
|
|
anchors.top: tag.bottom
|
|
anchors.topMargin: 20
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
width: parent.width * 0.7
|
|
horizontalAlignment: Text.AlignHCenter
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
font.pixelSize: root.font.pixelSize * 1.3
|
|
text: data.writeSuccess ? qsTr("Success!") : qsTr("To write, bring the NFC tag near your device.")
|
|
visible: nfc.nfcStatus != Wallet.NFC_Disabled
|
|
}
|
|
Flowee.Label {
|
|
id: errorLabel
|
|
anchors.top: infoLabel.bottom
|
|
anchors.topMargin: 20
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
width: parent.width / 3 * 2
|
|
horizontalAlignment: Text.AlignHCenter
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
font.pixelSize: root.font.pixelSize * 1.1
|
|
property int writeError: 0
|
|
color: mainWindow.errorRed
|
|
text: {
|
|
let e = writeError;
|
|
if (e === Wallet.NFC_WriteFailTagInvalid)
|
|
return qsTr("Invalid NFC tag")
|
|
if (e === Wallet.NFC_WriteFailRO)
|
|
return qsTr("Tag read-only. Try another.")
|
|
// our files are so tiny, this should not happen.
|
|
if (e === Wallet.NFC_WriteFailSize)
|
|
return "Tag is full. Try another"
|
|
if (e === Wallet.NFC_WriteFailOther)
|
|
return qsTr("Write failed. Try again.")
|
|
if (nfc.nfcStatus === Wallet.NFC_Disabled)
|
|
return qsTr("NFC disabled, please enable in settings")
|
|
return "";
|
|
}
|
|
}
|
|
Flowee.Button {
|
|
anchors.top: errorLabel.bottom
|
|
anchors.right: parent.right
|
|
text: qsTr("Settings")
|
|
visible: nfc.nfcStatus === Wallet.NFC_Disabled
|
|
onClicked: nfc.openSettings();
|
|
}
|
|
|
|
Flowee.BigButton {
|
|
id: closeButton
|
|
anchors.bottom: parent.bottom
|
|
anchors.bottomMargin: 20
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: (data.writeSuccess || nfc.nfcStatus == Wallet.NFC_Disabled) ? qsTr("Close") : qsTr("Cancel")
|
|
onClicked: {
|
|
thePile.pop();
|
|
thePile.pop();
|
|
}
|
|
}
|
|
}
|