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-12-13 10:45:26 +00:00
backButtonVisible: root . startupStore . currentStartupState ? root . startupStore . currentStartupState . displayBackButton
: false
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: {
2022-11-30 09:25:47 +00:00
switch ( root . startupStore . currentStartupState . stateType ) {
case Constants.startupState.allowNotifications:
2022-07-20 12:34:44 +00:00
return allowNotificationsViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.welcome:
2022-07-20 12:34:44 +00:00
return welcomeViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.welcomeNewStatusUser:
case Constants.startupState.welcomeOldStatusUser:
case Constants.startupState.userProfileImportSeedPhrase:
case Constants.startupState.profileFetchingAnnouncement:
case Constants.startupState.userProfileCreateSameChatKey:
2022-07-20 12:34:44 +00:00
return keysMainViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.userProfileCreate:
case Constants.startupState.userProfileChatKey:
2022-07-20 12:34:44 +00:00
return insertDetailsViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.userProfileCreatePassword:
2022-07-20 12:34:44 +00:00
return createPasswordViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.userProfileConfirmPassword:
2022-07-20 12:34:44 +00:00
return confirmPasswordViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.biometrics:
2022-07-20 12:34:44 +00:00
return touchIdAuthViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.userProfileEnterSeedPhrase:
2022-07-20 12:34:44 +00:00
return seedPhraseInputViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.login:
case Constants.startupState.loginPlugin:
case Constants.startupState.loginKeycardInsertKeycard:
case Constants.startupState.loginKeycardInsertedKeycard:
case Constants.startupState.loginKeycardReadingKeycard:
case Constants.startupState.loginKeycardRecognizedKeycard:
case Constants.startupState.loginKeycardEnterPin:
case Constants.startupState.loginKeycardEnterPassword:
case Constants.startupState.loginKeycardPinVerified:
case Constants.startupState.loginKeycardWrongKeycard:
case Constants.startupState.loginKeycardWrongPin:
case Constants.startupState.loginKeycardMaxPinRetriesReached:
case Constants.startupState.loginKeycardMaxPukRetriesReached:
case Constants.startupState.loginKeycardMaxPairingSlotsReached:
case Constants.startupState.loginKeycardEmpty:
case Constants.startupState.loginNotKeycard:
2022-07-20 12:34:44 +00:00
return loginViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.keycardPluginReader:
case Constants.startupState.keycardInsertKeycard:
case Constants.startupState.keycardInsertedKeycard:
case Constants.startupState.keycardReadingKeycard:
case Constants.startupState.keycardRecognizedKeycard:
2022-07-21 11:29:18 +00:00
return keycardInitViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.keycardCreatePin:
case Constants.startupState.keycardRepeatPin:
case Constants.startupState.keycardPinSet:
case Constants.startupState.keycardEnterPin:
case Constants.startupState.keycardWrongPin:
2022-07-21 11:29:18 +00:00
return keycardPinViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.keycardDisplaySeedPhrase:
2022-07-21 11:29:18 +00:00
return seedphraseViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.keycardEnterSeedPhraseWords:
2022-07-21 11:29:18 +00:00
return seedphraseWordsInputViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.keycardNotEmpty:
case Constants.startupState.keycardNotKeycard:
case Constants.startupState.keycardEmpty:
case Constants.startupState.keycardWrongKeycard:
case Constants.startupState.keycardLocked:
case Constants.startupState.keycardRecover:
case Constants.startupState.keycardMaxPairingSlotsReached:
case Constants.startupState.keycardMaxPinRetriesReached:
case Constants.startupState.keycardMaxPukRetriesReached:
2022-07-21 11:29:18 +00:00
return keycardStateViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.keycardEnterPuk:
case Constants.startupState.keycardWrongPuk:
2022-07-21 11:29:18 +00:00
return keycardPukViewComponent
2022-11-30 09:25:47 +00:00
case Constants.startupState.keycardWrongPuk:
return keycardPukViewComponent
case Constants.startupState.keycardWrongPuk:
return keycardPukViewComponent
case Constants.startupState.profileFetching:
case Constants.startupState.profileFetchingSuccess:
case Constants.startupState.profileFetchingTimeout:
return fetchingDataViewComponent
2022-07-21 11:29:18 +00:00
}
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
2022-11-30 09:25:47 +00:00
Component {
id: fetchingDataViewComponent
ProfileFetchingView {
startupStore: root . startupStore
}
}
2022-08-05 13:50:54 +00:00
Loader {
id: keycardPopup
active: false
sourceComponent: KeycardPopup {
2022-12-16 09:37:08 +00:00
anchors.centerIn: parent
2022-08-05 13:50:54 +00:00
sharedKeycardModule: root . startupStore . startupModuleInst . keycardSharedModule
}
onLoaded: {
keycardPopup . item . open ( )
}
}
2022-03-03 22:50:53 +00:00
}