-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(OnboardingLayout): Decompose into smaller, pure ui sub-flows
Closes: #16947
- Loading branch information
Showing
13 changed files
with
856 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
|
||
import StatusQ.Core.Utils 0.1 as SQUtils | ||
|
||
import AppLayouts.Onboarding2.pages 1.0 | ||
|
||
|
||
SQUtils.QObject { | ||
id: root | ||
|
||
required property StackView stackView | ||
required property var passwordStrengthScoreFunction | ||
|
||
signal finished(string password) | ||
|
||
function init() { | ||
root.stackView.push(createPasswordPage) | ||
} | ||
|
||
Component { | ||
id: createPasswordPage | ||
|
||
CreatePasswordPage { | ||
passwordStrengthScoreFunction: root.passwordStrengthScoreFunction | ||
|
||
onSetPasswordRequested: root.finished(password) | ||
} | ||
} | ||
} |
201 changes: 201 additions & 0 deletions
201
ui/app/AppLayouts/Onboarding2/KeycardCreateProfileFlow.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
|
||
import StatusQ.Core.Utils 0.1 as SQUtils | ||
|
||
import AppLayouts.Onboarding2.pages 1.0 | ||
import AppLayouts.Onboarding.enums 1.0 | ||
|
||
|
||
SQUtils.QObject { | ||
id: root | ||
|
||
required property StackView stackView | ||
|
||
required property int keycardState | ||
required property int addKeyPairState | ||
|
||
required property var seedWords | ||
required property var isSeedPhraseValid | ||
required property int splashScreenDurationMs | ||
|
||
property bool displayKeycardPromoBanner | ||
|
||
signal loginWithKeycardRequested | ||
signal keycardFactoryResetRequested | ||
signal keycardPinCreated(string pin) | ||
|
||
signal keypairAddTryAgainRequested | ||
signal reloadKeycardRequested | ||
signal createProfileWithoutKeycardRequested | ||
|
||
signal finished(bool fromBackupSeedphrase) | ||
|
||
function init() { | ||
root.stackView.push(d.initialComponent()) | ||
} | ||
|
||
QtObject { | ||
id: d | ||
|
||
property bool fromBackupSeedphrase | ||
|
||
function initialComponent() { | ||
if (root.keycardState === Onboarding.KeycardState.Empty) | ||
return createKeycardProfilePage | ||
|
||
if (root.keycardState === Onboarding.KeycardState.NotEmpty) | ||
return keycardNotEmptyPage | ||
|
||
return keycardIntroPage | ||
} | ||
} | ||
|
||
Component { | ||
id: keycardIntroPage | ||
|
||
KeycardIntroPage { | ||
keycardState: root.keycardState | ||
displayPromoBanner: root.displayKeycardPromoBanner | ||
|
||
onReloadKeycardRequested: { | ||
root.reloadKeycardRequested() | ||
root.stackView.replace(d.initialComponent(), | ||
StackView.PopTransition) | ||
} | ||
|
||
onKeycardFactoryResetRequested: root.keycardFactoryResetRequested() | ||
onEmptyKeycardDetected: root.stackView.replace(createKeycardProfilePage) | ||
onNotEmptyKeycardDetected: root.stackView.replace(keycardNotEmptyPage) | ||
} | ||
} | ||
|
||
Component { | ||
id: createKeycardProfilePage | ||
|
||
CreateKeycardProfilePage { | ||
onCreateKeycardProfileWithNewSeedphrase: | ||
root.stackView.push(backupSeedIntroPage) | ||
onCreateKeycardProfileWithExistingSeedphrase: | ||
root.stackView.push(seedphrasePage) | ||
} | ||
} | ||
|
||
Component { | ||
id: keycardNotEmptyPage | ||
|
||
KeycardNotEmptyPage { | ||
onReloadKeycardRequested: { | ||
root.reloadKeycardRequested() | ||
root.stackView.replace(d.initialComponent(), | ||
StackView.PopTransition) | ||
} | ||
|
||
onLoginWithThisKeycardRequested: root.loginWithKeycardRequested() | ||
onKeycardFactoryResetRequested: root.keycardFactoryResetRequested() | ||
} | ||
} | ||
|
||
Component { | ||
id: backupSeedIntroPage | ||
|
||
BackupSeedphraseIntro { | ||
onBackupSeedphraseRequested: root.stackView.push(backupSeedAcksPage) | ||
} | ||
} | ||
|
||
Component { | ||
id: backupSeedAcksPage | ||
|
||
BackupSeedphraseAcks { | ||
onBackupSeedphraseContinue: root.stackView.push(backupSeedRevealPage) | ||
} | ||
} | ||
|
||
Component { | ||
id: backupSeedRevealPage | ||
BackupSeedphraseReveal { | ||
seedWords: root.seedWords | ||
|
||
onBackupSeedphraseConfirmed: | ||
root.stackView.push(backupSeedVerifyPage) | ||
} | ||
} | ||
|
||
Component { | ||
id: backupSeedVerifyPage | ||
BackupSeedphraseVerify { | ||
seedWordsToVerify: { | ||
const randomIndexes = SQUtils.Utils.nSamples(4, root.seedWords.length) | ||
return randomIndexes.map(i => ({ seedWordNumber: i+1, | ||
seedWord: root.seedWords[i] | ||
})) | ||
} | ||
|
||
onBackupSeedphraseVerified: root.stackView.push(backupSeedOutroPage) | ||
} | ||
} | ||
|
||
Component { | ||
id: backupSeedOutroPage | ||
|
||
BackupSeedphraseOutro { | ||
onBackupSeedphraseRemovalConfirmed: | ||
root.stackView.push(keycardCreatePinPage) | ||
} | ||
} | ||
|
||
Component { | ||
id: seedphrasePage | ||
|
||
SeedphrasePage { | ||
title: qsTr("Create profile on empty Keycard using a recovery phrase") | ||
|
||
isSeedPhraseValid: root.isSeedPhraseValid | ||
onSeedphraseSubmitted: root.stackView.push(keycardCreatePinPage) | ||
|
||
StackView.onActivated: d.fromBackupSeedphrase = true | ||
} | ||
} | ||
|
||
Component { | ||
id: keycardCreatePinPage | ||
|
||
KeycardCreatePinPage { | ||
onKeycardPinCreated: { | ||
root.keycardPinCreated(pin) | ||
root.stackView.push(addKeypairPage) | ||
} | ||
} | ||
} | ||
|
||
Component { | ||
id: addKeypairPage | ||
|
||
KeycardAddKeyPairPage { | ||
readonly property bool backAvailableHint: false | ||
|
||
addKeyPairState: root.addKeyPairState | ||
timeoutInterval: root.splashScreenDurationMs | ||
|
||
onKeypairAddContinueRequested: root.finished(d.fromBackupSeedphrase) | ||
|
||
onKeypairAddTryAgainRequested: { | ||
root.stackView.replace(addKeypairPage) | ||
root.keypairAddTryAgainRequested() | ||
} | ||
|
||
onReloadKeycardRequested: { | ||
root.reloadKeycardRequested() | ||
|
||
const page = root.stackView.find( | ||
item => item instanceof CreateKeycardProfilePage) | ||
|
||
root.stackView.replace(page, d.initialComponent(), | ||
StackView.PopTransition) | ||
} | ||
|
||
onCreateProfilePageRequested: root.createProfileWithoutKeycardRequested() | ||
} | ||
} | ||
} |
Oops, something went wrong.