From ce32d2d42068c45ae99b4da58807f9a2c10f9425 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 31 Aug 2017 14:12:05 -0700 Subject: [PATCH] Checkout and Purchases --- .../qml/hifi/commerce/checkout/Checkout.qml | 54 ++++++++++++++++--- .../qml/hifi/commerce/purchases/Purchases.qml | 48 +++++++++++++++-- .../hifi/commerce/wallet/PassphraseModal.qml | 54 ++++++++++++++++--- .../qml/hifi/commerce/wallet/Wallet.qml | 10 +--- scripts/system/marketplaces/marketplaces.js | 1 + 5 files changed, 141 insertions(+), 26 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 109e357206..04dacf67c0 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -46,10 +46,38 @@ Rectangle { root.activeView = "needsLogIn"; } else if (isLoggedIn) { root.activeView = "initialize"; - commerce.getSecurityImage(); - commerce.getKeyFilePathIfExists(); - commerce.balance(); - commerce.inventory(); + commerce.getPassphraseSetupStatus(); + } + } + + onPassphraseSetupStatusResult: { + if (!passphraseIsSetup && root.activeView !== "notSetUp") { + root.activeView = "notSetUp"; + } else if (passphraseIsSetup && root.activeView === "initialize") { + commerce.getWalletAuthenticatedStatus(); + } + } + + onWalletAuthenticatedStatusResult: { + if (!isAuthenticated && !passphraseModal.visible) { + passphraseModal.visible = true; + } else if (isAuthenticated) { + if (passphraseModal.visible) { + passphraseModal.visible = false; + } + + if (!securityImageResultReceived) { + commerce.getSecurityImage(); + } + if (!keyFilePathIfExistsResultReceived) { + commerce.getKeyFilePathIfExists(); + } + if (!balanceReceived) { + commerce.balance(); + } + if (!purchasesReceived) { + commerce.inventory(); + } } } @@ -110,10 +138,6 @@ Rectangle { } } - HifiWallet.SecurityImageModel { - id: securityImageModel; - } - // // TITLE BAR START // @@ -221,7 +245,21 @@ Rectangle { } } + PassphraseModal { + id: passphraseModal; + z: 998; + visible: false; + anchors.top: titleBarContainer.bottom; + anchors.bottom: parent.bottom; + anchors.left: parent.left; + anchors.right: parent.right; + Connections { + onSendSignalToParent: { + sendToScript(msg); + } + } + } // // "WALLET NOT SET UP" START diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index bc843a140d..f9871d1b2a 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -41,9 +41,35 @@ Rectangle { root.activeView = "needsLogIn"; } else if (isLoggedIn) { root.activeView = "initialize"; - commerce.getSecurityImage(); - commerce.getKeyFilePathIfExists(); - commerce.inventory(); + commerce.getPassphraseSetupStatus(); + } + } + + onPassphraseSetupStatusResult: { + if (!passphraseIsSetup && root.activeView !== "notSetUp") { + root.activeView = "notSetUp"; + } else if (passphraseIsSetup && root.activeView === "initialize") { + commerce.getWalletAuthenticatedStatus(); + } + } + + onWalletAuthenticatedStatusResult: { + if (!isAuthenticated && !passphraseModal.visible) { + passphraseModal.visible = true; + } else if (isAuthenticated) { + if (passphraseModal.visible) { + passphraseModal.visible = false; + } + + if (!securityImageResultReceived) { + commerce.getSecurityImage(); + } + if (!keyFilePathIfExistsResultReceived) { + commerce.getKeyFilePathIfExists(); + } + if (!purchasesReceived) { + commerce.inventory(); + } } } @@ -191,6 +217,22 @@ Rectangle { commerce.getLoginStatus(); } } + + PassphraseModal { + id: passphraseModal; + z: 998; + visible: false; + anchors.top: titleBarContainer.bottom; + anchors.bottom: parent.bottom; + anchors.left: parent.left; + anchors.right: parent.right; + + Connections { + onSendSignalToParent: { + sendToScript(msg); + } + } + } // // "WALLET NOT SET UP" START diff --git a/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml b/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml index 71cb61686e..5a6df37485 100644 --- a/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml +++ b/interface/resources/qml/hifi/commerce/wallet/PassphraseModal.qml @@ -48,9 +48,9 @@ Item { onVisibleChanged: { if (visible) { passphraseField.focus = true; - sendSignalToWallet({method: 'disableHmdPreview'}); + sendSignalToParent({method: 'disableHmdPreview'}); } else { - sendSignalToWallet({method: 'maybeEnableHmdPreview'}); + sendSignalToParent({method: 'maybeEnableHmdPreview'}); } } @@ -96,9 +96,9 @@ Item { onFocusChanged: { if (focus) { - sendSignalToWallet({method: 'walletSetup_raiseKeyboard'}); + keyboard.raised = true; } else if (!passphraseFieldAgain.focus) { - sendSignalToWallet({method: 'walletSetup_lowerKeyboard'}); + keyboard.raised = false; } } @@ -106,7 +106,7 @@ Item { anchors.fill: parent; onClicked: { parent.focus = true; - sendSignalToWallet({method: 'walletSetup_raiseKeyboard'}); + keyboard.raised = true; } } @@ -206,7 +206,7 @@ Item { width: parent.width/2 - anchors.leftMargin*2; text: "Cancel" onClicked: { - sendSignalToWallet({method: 'passphrasePopup_cancelClicked'}); + sendSignalToParent({method: 'passphrasePopup_cancelClicked'}); } } @@ -228,5 +228,45 @@ Item { } } - signal sendSignalToWallet(var msg); + Item { + id: keyboardContainer; + z: 999; + visible: keyboard.raised; + property bool punctuationMode: false; + anchors { + bottom: parent.bottom; + left: parent.left; + right: parent.right; + } + + Image { + id: lowerKeyboardButton; + source: "images/lowerKeyboard.png"; + anchors.horizontalCenter: parent.horizontalCenter; + anchors.bottom: keyboard.top; + height: 30; + width: 120; + + MouseArea { + anchors.fill: parent; + + onClicked: { + root.keyboardRaised = false; + } + } + } + + HifiControlsUit.Keyboard { + id: keyboard; + raised: HMD.mounted && root.keyboardRaised; + numeric: parent.punctuationMode; + anchors { + bottom: parent.bottom; + left: parent.left; + right: parent.right; + } + } + } + + signal sendSignalToParent(var msg); } diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index 04278e85a9..8858c25964 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -253,14 +253,8 @@ Rectangle { anchors.right: parent.right; Connections { - onSendSignalToWallet: { - if (msg.method === 'walletSetup_raiseKeyboard') { - root.keyboardRaised = true; - } else if (msg.method === 'walletSetup_lowerKeyboard') { - root.keyboardRaised = false; - } else { - sendToScript(msg); - } + onSendSignalToParent: { + sendToScript(msg); } } } diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 7d1aaee157..ccaa03baa8 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -231,6 +231,7 @@ case 'purchases_goToMarketplaceClicked': tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL); break; + case 'passphrasePopup_cancelClicked': case 'needsLogIn_cancelClicked': tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL); break;