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-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-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . welcome )
{
return welcomeViewComponent
2022-03-07 22:59:38 +00:00
}
2022-07-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . welcomeNewStatusUser ||
root . startupStore . currentStartupState . stateType === Constants . startupState . welcomeOldStatusUser ||
root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileImportSeedPhrase )
{
return keysMainViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileCreate ||
root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileChatKey )
{
return insertDetailsViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileCreatePassword )
{
return createPasswordViewComponent
2022-03-01 15:59:38 +00:00
}
2022-07-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileConfirmPassword )
{
return confirmPasswordViewComponent
2022-03-01 15:59:38 +00:00
}
2022-07-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . biometrics )
{
return touchIdAuthViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . userProfileEnterSeedPhrase )
{
return seedPhraseInputViewComponent
2022-03-03 22:50:53 +00:00
}
2022-07-20 12:34:44 +00:00
else if ( root . startupStore . currentStartupState . stateType === Constants . startupState . login )
{
return loginViewComponent
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" )
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 ( "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-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
}
}
}