2021-09-24 15:03:57 +03:00
|
|
|
import QtQuick 2.13
|
2021-10-12 20:26:02 +02:00
|
|
|
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared.keycard 1.0
|
2021-10-12 20:26:02 +02:00
|
|
|
import "../popups"
|
|
|
|
import "../stores"
|
2021-09-24 15:03:57 +03:00
|
|
|
|
|
|
|
Item {
|
2021-10-01 13:22:51 +03:00
|
|
|
enum OnboardingFlow {
|
|
|
|
Recover,
|
|
|
|
Generate,
|
|
|
|
ImportMnemonic
|
|
|
|
}
|
|
|
|
|
2021-09-24 15:03:57 +03:00
|
|
|
property var onClosed: function () {}
|
2021-09-27 16:55:39 +03:00
|
|
|
property bool connected: false
|
2021-10-01 13:22:51 +03:00
|
|
|
property int flow: OnboardingFlow.Recover
|
2021-09-27 16:55:39 +03:00
|
|
|
|
2021-09-24 15:03:57 +03:00
|
|
|
id: keycardView
|
|
|
|
Component.onCompleted: {
|
2021-09-29 16:23:28 +03:00
|
|
|
insertCard.open()
|
2021-10-12 20:26:02 +02:00
|
|
|
KeycardStore.startConnection()
|
2021-09-27 16:55:39 +03:00
|
|
|
}
|
|
|
|
|
2021-10-12 20:26:02 +02:00
|
|
|
KeycardCreatePINModal {
|
2021-09-24 15:03:57 +03:00
|
|
|
id: createPinModal
|
2021-10-12 20:26:02 +02:00
|
|
|
onSubmitBtnClicked: KeycardStore.init(pin)
|
2021-09-24 15:03:57 +03:00
|
|
|
onClosed: function () {
|
2021-10-01 13:22:51 +03:00
|
|
|
if (!createPinModal.submitted) {
|
|
|
|
keycardView.onClosed()
|
|
|
|
}
|
2021-09-24 15:03:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PairingModal {
|
|
|
|
id: pairingModal
|
|
|
|
onClosed: function () {
|
2021-09-30 14:52:46 +03:00
|
|
|
if (!pairingModal.submitted) {
|
|
|
|
keycardView.onClosed()
|
|
|
|
}
|
2021-09-24 15:03:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PINModal {
|
|
|
|
id: pinModal
|
|
|
|
onClosed: function () {
|
2021-10-01 13:22:51 +03:00
|
|
|
if (!pinModal.submitted) {
|
|
|
|
keycardView.onClosed()
|
|
|
|
}
|
2021-09-27 10:36:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InsertCard {
|
|
|
|
id: insertCard
|
2021-09-27 16:55:39 +03:00
|
|
|
onCancel: function() {
|
2021-09-24 15:03:57 +03:00
|
|
|
keycardView.onClosed()
|
|
|
|
}
|
|
|
|
}
|
2021-09-30 14:52:46 +03:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
id: connection
|
2021-10-12 20:26:02 +02:00
|
|
|
target: OnboardingStore.keycardModelInst
|
2021-09-30 14:52:46 +03:00
|
|
|
ignoreUnknownSignals: true
|
|
|
|
|
|
|
|
onCardUnpaired: {
|
|
|
|
pairingModal.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
onCardPaired: {
|
2021-10-01 13:22:51 +03:00
|
|
|
pinModal.open()
|
|
|
|
}
|
2021-09-30 14:52:46 +03:00
|
|
|
|
2021-10-01 13:22:51 +03:00
|
|
|
onCardAuthenticated: {
|
|
|
|
switch (flow) {
|
|
|
|
case OnboardingFlow.Recover: {
|
2021-10-12 20:26:02 +02:00
|
|
|
KeycardStore.recoverAccount();
|
2021-10-01 13:22:51 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OnboardingFlow.Generate: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OnboardingFlow.ImportMnemonic: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-09-30 14:52:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: support the states below
|
|
|
|
|
|
|
|
onCardPreInit: {
|
2021-10-01 13:22:51 +03:00
|
|
|
createPinModal.open()
|
2021-09-30 14:52:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onCardFrozen: {
|
|
|
|
keycardView.onClosed()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
onCardBlocked: {
|
|
|
|
keycardView.onClosed()
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: handle these by showing an error an prompting for another card
|
|
|
|
// later add factory reset option for the NoFreeSlots case
|
|
|
|
|
|
|
|
onCardNoFreeSlots: {
|
2021-10-01 13:22:51 +03:00
|
|
|
keycardView.onClosed()
|
2021-09-30 14:52:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onCardNotKeycard: {
|
|
|
|
keycardView.onClosed()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-10-12 20:26:02 +02:00
|
|
|
}
|