2022-07-20 12:34:44 +00:00
import QtQuick 2.14
import QtQuick . Controls 2.14
import QtQuick . Dialogs 1.3
2022-03-03 22:50:53 +00:00
import utils 1.0
2022-08-05 13:50:54 +00:00
import shared . popups . keycard 1.0
2022-03-03 22:50:53 +00:00
2022-07-20 12:34:44 +00:00
import "controls"
2022-03-03 22:50:53 +00:00
import "views"
import "stores"
2022-07-20 12:34:44 +00:00
OnboardingBasePage {
2022-03-03 22:50:53 +00:00
id: root
2022-03-07 22:59:38 +00:00
2022-07-20 12:34:44 +00:00
property var startupStore: StartupStore { }
2022-03-03 22:50:53 +00:00
2022-07-20 12:34:44 +00:00
backButtonVisible: root . startupStore . currentStartupState . displayBackButton
2022-03-03 22:50:53 +00:00
2022-07-20 12:34:44 +00:00
onBackClicked: {
root . startupStore . backAction ( )
}
2022-05-20 17:14:39 +00:00
2022-07-20 12:34:44 +00:00
function unload ( ) {
loader . sourceComponent = undefined
}
2022-05-20 17:14:39 +00:00
2022-07-20 12:34:44 +00:00
Loader {
id: loader
anchors.fill: parent
sourceComponent: {
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . allowNotifications )
{
return allowNotificationsViewComponent
2022-05-20 17:14:39 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . welcome )
2022-07-20 12:34:44 +00:00
{
return welcomeViewComponent
2022-03-07 22:59:38 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . welcomeNewStatusUser ||
root . startupStore . currentStartupState . stateType === Constants . startupState . welcomeOldStatusUser ||
root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileImportSeedPhrase )
2022-07-20 12:34:44 +00:00
{
return keysMainViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileCreate ||
root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileChatKey )
2022-07-20 12:34:44 +00:00
{
return insertDetailsViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileCreatePassword )
2022-07-20 12:34:44 +00:00
{
return createPasswordViewComponent
2022-03-01 15:59:38 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileConfirmPassword )
2022-07-20 12:34:44 +00:00
{
return confirmPasswordViewComponent
2022-03-01 15:59:38 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . biometrics )
2022-07-20 12:34:44 +00:00
{
return touchIdAuthViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileEnterSeedPhrase )
2022-07-20 12:34:44 +00:00
{
return seedPhraseInputViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . login ||
2022-09-13 09:55:19 +00:00
root . startupStore . currentStartupState . stateType === Constants . startupState . loginPlugin ||
2022-07-21 11:29:18 +00:00
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardInsertKeycard ||
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardReadingKeycard ||
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardEnterPin ||
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardWrongKeycard ||
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardWrongPin ||
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardMaxPinRetriesReached ||
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardMaxPukRetriesReached ||
2022-09-13 09:55:19 +00:00
root . startupStore . currentStartupState . stateType === Constants . startupState . loginKeycardEmpty ||
root . startupStore . currentStartupState . stateType === Constants . startupState . loginNotKeycard )
2022-07-20 12:34:44 +00:00
{
return loginViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-21 11:29:18 +00:00
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . keycardPluginReader ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardInsertKeycard ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardReadingKeycard )
{
return keycardInitViewComponent
}
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . keycardCreatePin ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardRepeatPin ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardPinSet ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardEnterPin ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardWrongPin )
{
return keycardPinViewComponent
}
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . keycardDisplaySeedPhrase )
{
return seedphraseViewComponent
}
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . keycardEnterSeedPhraseWords )
{
return seedphraseWordsInputViewComponent
}
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . keycardNotEmpty ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardEmpty ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardLocked ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardRecover ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardMaxPairingSlotsReached ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardMaxPinRetriesReached ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardMaxPukRetriesReached )
{
return keycardStateViewComponent
}
if ( root . startupStore . currentStartupState . stateType === Constants . startupState . keycardEnterPuk ||
root . startupStore . currentStartupState . stateType === Constants . startupState . keycardWrongPuk )
{
return keycardPukViewComponent
}
2022-03-03 22:50:53 +00:00
2022-07-20 12:34:44 +00:00
return undefined
2022-03-03 22:50:53 +00:00
}
2022-07-20 12:34:44 +00:00
}
2022-03-03 22:50:53 +00:00
2022-07-20 12:34:44 +00:00
Connections {
target: root . startupStore . startupModuleInst
onAccountSetupError: {
if ( error === Constants . existingAccountError ) {
msgDialog . title = qsTr ( "Keys for this account already exist" )
msgDialog . text = qsTr ( "Keys for this account already exist and can't be added again. If you've lost your password, passcode or Keycard, uninstall the app, reinstall and access your keys by entering your seed phrase" )
} else {
msgDialog . title = qsTr ( "Login failed" )
msgDialog . text = qsTr ( "Login failed. Please re-enter your password and try again." )
}
msgDialog . open ( )
}
2022-03-03 22:50:53 +00:00
2022-07-20 12:34:44 +00:00
onAccountImportError: {
if ( error === Constants . existingAccountError ) {
msgDialog . title = qsTr ( "Keys for this account already exist" )
2022-07-21 11:29:18 +00:00
msgDialog . text = qsTr ( " Keys for this account already exist and can 't be added again. If you' ve lost \
your password , passcode or Keycard , uninstall the app , reinstall and access your keys by entering your seed phrase . In \
case of Keycard try recovering using PUK or reinstall the app and try login with the Keycard option . " )
2022-07-20 12:34:44 +00:00
} else {
msgDialog . title = qsTr ( "Error importing seed" )
msgDialog . text = error
2022-03-03 22:50:53 +00:00
}
2022-07-20 12:34:44 +00:00
msgDialog . open ( )
2022-03-03 22:50:53 +00:00
}
2022-09-02 11:03:40 +00:00
onDisplayKeycardSharedModuleFlow: {
2022-08-05 13:50:54 +00:00
keycardPopup . active = true
}
onDestroyKeycardSharedModuleFlow: {
keycardPopup . active = false
}
2022-03-03 22:50:53 +00:00
}
2022-07-20 12:34:44 +00:00
MessageDialog {
id: msgDialog
title: qsTr ( "Login failed" )
text: qsTr ( "Login failed. Please re-enter your password and try again." )
icon: StandardIcon . Critical
standardButtons: StandardButton . Ok
onAccepted: {
console . log ( "TODO: restart flow..." )
}
}
Component {
id: allowNotificationsViewComponent
2022-05-20 17:14:39 +00:00
AllowNotificationsView {
2022-07-20 12:34:44 +00:00
startupStore: root . startupStore
2022-05-20 17:14:39 +00:00
}
}
2022-07-20 12:34:44 +00:00
Component {
id: welcomeViewComponent
2022-03-04 23:31:31 +00:00
WelcomeView {
2022-07-20 12:34:44 +00:00
startupStore: root . startupStore
2022-03-04 23:31:31 +00:00
}
}
2022-07-20 12:34:44 +00:00
Component {
id: keysMainViewComponent
2022-03-03 22:50:53 +00:00
KeysMainView {
2022-07-20 12:34:44 +00:00
startupStore: root . startupStore
2022-03-03 22:50:53 +00:00
}
}
2022-07-20 12:34:44 +00:00
Component {
id: insertDetailsViewComponent
InsertDetailsView {
startupStore: root . startupStore
2022-03-03 22:50:53 +00:00
}
}
2022-07-20 12:34:44 +00:00
Component {
id: createPasswordViewComponent
CreatePasswordView {
startupStore: root . startupStore
2022-03-03 22:50:53 +00:00
}
}
2022-07-20 12:34:44 +00:00
Component {
id: confirmPasswordViewComponent
ConfirmPasswordView {
startupStore: root . startupStore
}
}
Component {
id: touchIdAuthViewComponent
TouchIDAuthView {
startupStore: root . startupStore
2022-03-03 22:50:53 +00:00
}
}
2022-07-20 12:34:44 +00:00
Component {
id: seedPhraseInputViewComponent
SeedPhraseInputView {
startupStore: root . startupStore
}
}
Component {
id: loginViewComponent
2022-03-03 22:50:53 +00:00
LoginView {
2022-07-20 12:34:44 +00:00
startupStore: root . startupStore
2022-03-03 22:50:53 +00:00
}
}
2022-07-21 11:29:18 +00:00
Component {
id: keycardInitViewComponent
KeycardInitView {
startupStore: root . startupStore
}
}
Component {
id: keycardPinViewComponent
KeycardPinView {
startupStore: root . startupStore
}
}
Component {
id: keycardPukViewComponent
KeycardPukView {
startupStore: root . startupStore
}
}
Component {
id: seedphraseViewComponent
SeedPhraseView {
startupStore: root . startupStore
}
}
Component {
id: seedphraseWordsInputViewComponent
SeedPhraseWordsInputView {
startupStore: root . startupStore
}
}
Component {
id: keycardStateViewComponent
KeycardStateView {
startupStore: root . startupStore
}
}
2022-08-05 13:50:54 +00:00
Loader {
id: keycardPopup
active: false
sourceComponent: KeycardPopup {
sharedKeycardModule: root . startupStore . startupModuleInst . keycardSharedModule
}
onLoaded: {
keycardPopup . item . open ( )
}
}
2022-03-03 22:50:53 +00:00
}